Twitter API - Determining local time in PHP

The twitter API provides all tweets in UTC time. You can also get the UTC offset and the "time zone" for the logged in user:

e.g.

created_at = Mon Jun 11 13:17:11 +0000 2012 utc_offset = -18000 time_zone = Eastern Time (US & Canada)

I have no problem converting the created_at time to a timestamp and then adding the utc_offset, but the utc_offset does not take daylight savings time into account. So during DST, all of my times are off by 1 hour.

The other problem is that the time_zone value that is provided by Twitter API does not match the php timezone format (http://www.php.net/manual/en/timezones.america.php).

Does anyone have an idea on how to take into account DST to display an accurate local time to the user?

I'm starting to think maybe using client side scripting to convert the UTC time is my best bet.

Answers


I think you are right. You really only have 2 options:

  • Manually create an array (unless someone else has already done the leg work for you somewhere..) which holds the Twitter API time_zone strings and indices and the PHP equivalent as values, or
  • Use a simple JavaScript to modify the standardised time string on the client end.

I know what I'd prefer.

The second answer on this post has a nice example for the javascript Parsing Twitter API Datestamp


Need Your Help

what is the possible reason of facebook login in magento website redirect to blank page?

php facebook magento

I installed an facebook login extension named inchoo.First time it runs perfect in localhost,ie. i logged in through it into my magento website successfully.Then after, two issues are coming :-

Default destination of JBoss ESB content based routing using Drools

jboss esb drools

I'm using content based routing with Drools in JBoss ESB. I have several rules that select the destinations to use base on message's content. If incoming message's content is not recognized, this m...