PHP中的UTC时间格式到毫秒(本地时区问题)

时间:2014-11-29 13:28:28

标签: php datetime utc

我想从这个2014-09-15T10:27:29Z

之类的日期获得毫秒

我尝试了以下

return strtotime('2014-09-15T10:27:29Z');

但它返回一个警告:

It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/New_York' for 'EST/-5.0/no DST'

所以,我必须使用函数date_default_timezone_set但不固定为'America/New_York'

$userZone = //I don't know what to put here
date_default_timezone_set($userZone);
return strtotime('2014-09-15T10:27:29Z');

如何获取用户时区?

1 个答案:

答案 0 :(得分:0)

日期/时间字符串末尾的Z表示Zulu时间,或UTC,因为它更常见。

  

UTC时区有时用字母Z表示 - 对等效航海时区(GMT)的引用,自1950年以来用Z表示。该字母还指"区域描述& #34;零小时,自1920年以来一直使用(见时区历史)。由于Z的北约语音字母和业余无线电字是"祖鲁",UTC有时被称为祖鲁时间。在航空领域尤其如此,祖鲁是通用标准。这样可以确保所有飞行员无论身在何处都使用相同的24小时制,从而避免在时区之间飞行时造成混淆。

相关问题