idi*_*ous 0 php timezone datetime
我有一个字符串"2013-10-09 00:00:00",我使用下面的代码将其更改为时间戳
date_default_timezone_set($timeZone);
$timeStamp = strtotime("2013-10-09 00:00:00"); //echos 1381269600
Run Code Online (Sandbox Code Playgroud)
当我做
date_default_timezone_set($timeZone);
date("Y-m-d H:m",$timeStamp);
Run Code Online (Sandbox Code Playgroud)
我得到2013年10月9日00:10:00.这完全是奇怪的.为什么我会得到这10分钟的差异?
因为你使用的m是月份而不是分钟.你需要使用i.
见http://php.net/manual/en/function.date.php
你的代码应该是
date("Y-m-d H:i", $timeStamp);
Run Code Online (Sandbox Code Playgroud)