我正在尝试使用 strtotime 转换以下日期:
07/09/2009 17:01:27
这是 9 月 7 日的欧洲/伦敦时区格式
该功能正在反转月份和日期,有什么解决方法吗?
谢谢
最佳答案
更改 /
为 -
, 好像 PHP 得到 /
作为美国格式,和 -
作为欧洲人。你可以在这里看到:
$date = "06/10/2011 14:28"; // 6 october 2011 2:28 pm
$otherDate = "06-10-2011 14:28"; // 6 october 2011 2:28 pm
echo $stamp = strtotime($date) . "<br />"; // outputs 1307708880
echo $otherStamp = strtotime($otherDate) . "<br />"; // outputs 1317904080
echo date("d-m", $stamp); // outputs 10-06
echo date("d-m", $otherStamp); // outputs 06-10
http://www.php.net/manual/es/function.strtotime.php#106043
关于php - 具有欧洲日期格式的 Strtotime,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1389830/