$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”有01:00而其他人有00:00?我使用的是PHP 5.5.29。
发布于 2016-10-17 20:00:42
这与“夏令节约时间”(DST)有关。我的php.ini时区当前设置为
date.timezone = America/Sao_Paulo在巴西,我们在2016-10-16年进入了“夏令时间”(DST),所以它有01:00:00。有意思,这是我多年来第一次想到这件事。
发布于 2016-10-17 20:00:52
这个问题的作者似乎是住在巴西,在巴西,DST实际上发生在2016年10月16日- https://www.timeanddate.com/time/change/brazil/brasilia?year=2016。
https://stackoverflow.com/questions/40094427
复制相似问题