Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 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

like image 966
Garbit Avatar asked Jun 02 '11 16:06

Garbit


People also ask

Is twitter time local time?

the timezone of each tweet is automatically converted to the local timezone.

Does twitter use UTC?

Timezones, Accounts, and BillingDatetime values are always returned in UTC time (as indicated by the Z at the end of the datetime value.)

Why is my time on twitter wrong?

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.

How can you tell the exact time on twitter?

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.


1 Answers

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 the date() 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.

like image 186
arcain Avatar answered Sep 28 '22 07:09

arcain