[英]Strange behaviour in PHP strtotime
$one = '2016-10-11';
$two = '2016-10-13';
$three = '2016-10-15';
$four = '2016-10-16';
$five = '2016-10-17';
$output_format = 'Y-m-d H:i:s';
var_dump(
strtotime($one),
strtotime($two),
strtotime($three),
strtotime($four),
strtotime($five),
date($output_format, strtotime($one)),
date($output_format, strtotime($two)),
date($output_format, strtotime($three)),
date($output_format, strtotime($four)),
date($output_format, strtotime($five))
);
这输出
int 1476154800
int 1476327600
int 1476500400
int 1476586800
int 1476669600
string '2016-10-11 00:00:00' (length=19)
string '2016-10-13 00:00:00' (length=19)
string '2016-10-15 00:00:00' (length=19)
string '2016-10-16 01:00:00' (length=19)
string '2016-10-17 00:00:00' (length=19)
为什么'2016-10-16 01:00:00'有01:00:00而其他人有00:00:00? 我使用的是PHP 5.5.29。
该问题的作者似乎生活在巴西,DST实际上发生在2016年10月16日 - https://www.timeanddate.com/time/change/brazil/brasilia?year=2016
事实证明这与“夏令时”(DST)有关。 我的php.ini时区目前设置为
date.timezone = America/Sao_Paulo
在巴西,我们在2016-10-16进入了“夏令时”(DST),这就是为什么它在01:00:00。 有趣的是,这是我多年来第一次遇到它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.