Anuradha
Anuradha

Reputation: 580

Convert Instagram response device time stamp to readable date time

I'm using Instagram-API-python to create an application. I'm getting a JSON response with below value.

'device_timestamp': 607873890651

I tried to convert this value to readable using python.

import time
readable = time.ctime(607873890651)
print(readable)

It gives following result and seems it is not correct.

Sun Oct  3 16:00:51 21232

I'm not much familiar with the Instagram-API-python. Please someone can help me to solve this problem.

Upvotes: 2

Views: 2120

Answers (3)

Dyno Cris
Dyno Cris

Reputation: 2414

Don't use device_timestamp but use taken_at field. Then taken_at need multiply to 1000.

In Java it looks like this

Date data = new Date(taken_at * 1000);

Upvotes: 1

Nenad Anchev
Nenad Anchev

Reputation: 11

Use the mentioned ctime conversion, but take the 'taken_at' field if available.

Upvotes: 1

Charles Gosselin
Charles Gosselin

Reputation: 13

The data is very likely to be incorrect.

Timestamp is a very standard way to store a date-time. Counting the seconds that passed since January 1st, 1970, also known as the UNIX Epoch.

I looked for "Instagram 'device_timestamp'" on Google and all the user-provided values made sense, but yours doesn't.

This is probably an error from the database, it happens.

Upvotes: 1

Related Questions