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 in 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
the timezone of each tweet is automatically converted to the local timezone.
Timezones, Accounts, and BillingDatetime values are always returned in UTC time (as indicated by the Z at the end of the datetime value.)
Step 1: First of all, you have to sign in to your account on twitter.com. Step 2: Then, you need to click on your profile icon and select Settings from the drop-down menu. Step 3: Here, you have to click Account and then choose your time zone from the Time zone drop-down menu.
It's actually incredibly simple – all you have to do is place your mouse pointer over the timestamp on Twitter.com, either in your feed or within the desired tweet, and Twitter will show you the time the tweet was posted via a little pop-up.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With