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:
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.
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
I know what I'd prefer.