Twitter timezone & created_at (utc time) values to calculate what time zone the user is in
I'm trying to estimate a twitter user's location based on the time_zone or created_at value in a given tweet object. However it seems that all created_at values I've come across are just in a pointless localised time and the time zone they supply isn't in the most helpful format
example tweet
"created_at":"Thu Jun 02 14:41:24 +0000 2011"
"time_zone":null
OR
"created_at":"Sun Jan 09 05:03:52 +0000 2011"
"time_zone":"Mountain Time (US & Canada)"
Both of these times aren't i开发者_如何学运维n UTC time and the time_zone isn't in any particular standard format with the rest of the world
I'm probably coming across really annoying, I'm tired and hot and been looking for this solution for too long :|
thanks,
Andy
This answer details how to convert a Twitter date into something PHP can work with; synopsis below.
strtotime("dateString");
gets it into the native PHP date format, then you can work with thedate()
function to get it printed out how you'd like it.
As for the time zone, you can use the value of the utc_offset
property of the user
object to calculate it. For example, my profile's utc_offset
is:
"utc_offset":-21600
Just divide that value by 3600 and that will give you -6, which is the US Central time zone. These will be absolute offsets and will not change whether the time zone honors daylight savings time.
精彩评论