Twitter时区& created_at(世界标准时间)值可计算用户所在的时区 [英] Twitter timezone & created_at (utc time) values to calculate what time zone the user is in
问题描述
我试图基于给定tweet对象中的time_zone或created_at值来估计Twitter用户的位置.但是,似乎我遇到的所有created_at值都只是毫无意义的本地化时间,它们提供的时区并不是最有用的格式
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
示例推文
"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)"
这两个时间都不是UTC时间,并且time_zone在世界其他地方也不是任何特定的标准格式
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 :|
谢谢
安迪
推荐答案
此答案详细说明如何将Twitter日期转换为PHP可以使用的日期;概要如下.
This answer details how to convert a Twitter date into something PHP can work with; synopsis below.
strtotime("dateString");
将其放入 本机PHP日期格式,然后您 可以与date()
函数一起使用 印出您想要的方式.
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.
对于时区,可以使用user
对象的utc_offset
属性的值进行计算.例如,我的个人资料的utc_offset
是:
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
将该值除以3600,将得出-6,这是美国中部时区.这些将是绝对偏移量,并且不会更改时区是否符合夏令时.
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.
这篇关于Twitter时区& created_at(世界标准时间)值可计算用户所在的时区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!