使用ISO 8601日期转换的php字符串的可能原因再增加一个小时(Possible causes for php string with ISO 8601 date conversion adds one more hour)
基本上我有这个:
$data_start = '2012-06-07T13:00:00Z'; if (($timestamp = strtotime($data_start)) === false) { return "The string ($data_start) is bogus"; } else { return "$data_start == " . date('l dS \o\f F Y H:i:s', $timestamp); }它正在回归:
"Thursday 07th of June 2012 14:00:00"为什么在strtotime增加1个小时!? 与时区有什么关系?
Basically I've got this:
$data_start = '2012-06-07T13:00:00Z'; if (($timestamp = strtotime($data_start)) === false) { return "The string ($data_start) is bogus"; } else { return "$data_start == " . date('l dS \o\f F Y H:i:s', $timestamp); }And it is returning:
"Thursday 07th of June 2012 14:00:00"Why on earth is strtotime adding 1 more hour!? Anything to do with timezones?
最满意答案
$ data_start上的最后一个Z表示日期是UTC时间。 我想你的当地时区是UTC +1?
如果你想一直使用UTC时间,你可以使用类似:date_default_timezone_set('UTC')来绕过你当地的时区设置
the last Z on $data_start tells that the date is in UTC time. I suppose your local timezone is UTC +1 ?
if you want to always work with UTC time, you can use something like : date_default_timezone_set ('UTC') to bypass your local timezone setting
更多推荐
发布评论