kam*_*lot 4 php time timestamp strtotime
所以我使用strtotime将此字符串转换为时间戳:
strtotime("1 Nov, 2001");
Run Code Online (Sandbox Code Playgroud)
这导致时间戳1320177660
但是当我尝试使用在线时间戳转换器再次将1320177660转换为正常日期格式时,年份最终是2011年而不是2001年......
我究竟做错了什么?
正如@Evan Mulawski的评论所说,"2001"被解释为时间,而不是一年.取出逗号让PHP将"2001"解释为一年:
<?php
$ts = strtotime("1 Nov 2001");
echo $ts . "\n";
$st = strftime("%B %d, %Y, %H:%M:%S", $ts);
echo $st . "\n";
?>
Run Code Online (Sandbox Code Playgroud)
输出:
1004590800
2001年11月1日,00:00:00