1

The Instagram API return a created_time field attached to each media (example of API response here).

The value of this field is a simple timestamp. My question is : In which timezone is it ? I need this information to convert the timezone in Europe/Paris, if needed, before store it in my database (I assumed that all date related datas in my database are in Europe/Paris).

Thank you !

Tmb
  • 450
  • 12
  • 20

2 Answers2

1

The date is in UTC so you can easily convert this to your locale. However if you want to know the local time of the place where the picture was taken then I think you would need to get the timezone from the longitude and latitude of the location attribute in the /media/search endpoint.

EDIT: This is the function I ended up creating:

function roughlyDetermineTimezoneOffset(lng, lat) {

        var sign = lat?lat<0?-1:1:0;
        return sign * lng * 24 / 360;
    }

Based upon this article: rough estimate of the time offset from GMT from latitude longitude

Community
  • 1
  • 1
Stevo
  • 2,601
  • 3
  • 24
  • 32
  • I ended up doing a rough and ready calculation based on this article. http://stackoverflow.com/questions/1058342/rough-estimate-of-the-time-offset-from-gmt-from-latitude-longitude – Stevo Oct 15 '15 at 12:53
0

The field looks like the text representation of a Unix Timestamp, which is:

The number of seconds that have elapsed since 00:00:00 Coordinated Universal Time (UTC)

Some datetime libraries will convert that to a localtime, but the exact behavior will be determined by your programming language and datetime libary.

Just as a side note, it is generally considered best practice to store datetimes in your database in UTC, and only convert to a local datetime for presentation to a user. See https://stackoverflow.com/a/2532962/3108853 for more discussion.

Community
  • 1
  • 1
lsowen
  • 3,728
  • 1
  • 21
  • 23
  • 1
    So you said there is no timezone adjustment on this field? I would like to be sure about that, and there is no information in the doc (which is very poor by the way...) – Tmb Jun 15 '15 at 15:56
  • No, not the field it itself. You can do what timezone adjustment you want once you have converted the timestamp into a datetime in whatever programming language you are using. – lsowen Jun 15 '15 at 15:58
  • @Isowen yes i already do a conversion in Europe/Paris, because i assumed the timestamp returned by the API is UTC, but i can't find confirmation about that anywhere. I just want to be sure, because it's important in the app i'm currently working on. – Tmb Jun 15 '15 at 16:02