Facebook API, time zone and country

I am developing a site where users can login with their Facebook credentials.

Now I have a date and time problem. My local system is using Roman Standard Time, which is different from what Facebook uses.

Where I am local we are using DST and depending on the time of year we can be either UTC + 1 or UTC + 2.

My question is, "How can I convert the Facebook time to the format my local system will use, given the periodic changes between UTC + 1 and UTC + 2?"

+3


source to share


2 answers


Per this documentation , the only way to change their timezone for a user is to change their computer timezone and log out and back to facebook. This would lead me to believe that they are just taking the UTC offset in JavaScript in the browser and passing it back to the server.

So the field value timezone

returned from the Facebook API is probably an offset as of the last time the user was logged in.



It is also possible that it represents an offset to the user's registration date and that it cannot change. I couldn't find any reference in the documentation, so you would need to experiment.

It is impossible to get the time zone from the offset alone at any time. There are many time zones with the same offset. For a helpful analogy see my related answer here .

+3


source


Working with Facebook is hard. Here's my experience:

  • If you get a 24 character ISO 8601 timestamp, for example 2013-01-17T08:00:00+0000

    , the offset from UTC will be determined. You just need to parse this and convert it to local offset.
  • If you get a Unix timestamp, for example 1358694451

    , it is in the timezone defined as America/Los_Angeles

    in PHP.
  • If you get an ISO 8601 timestamp that is 19 characters or less, for example, 2013-01-17

    or 2013-01-17T08:00:00

    than the time is either relative to the locale of an object with that time, or if the object is not locale, then it is in the timezone America/Los_Angeles

    .


I'm not a C # developer, but this MSDN article can help with converting timezones. http://msdn.microsoft.com/en-us/library/bb397769.aspx

+1


source







All Articles