题
<?php
echo "Hello?";
$thetime = strtotime("Wed Dec 16 2009 00:00:00 GMT-0500 (Eastern Standard Time)");
var_dump($thetime);
?>
该代码评估为“ bool(false)”;但是,只需删除“(东部标准时间)”,允许strtotime函数正确评估。有什么想法,为什么strtotime在字符串的时区域窒息?
解决方案
看起来很大,在这种情况下,您应该制定正则表达式或手动将字符串分开。但是我想您想使用以下代码:
<?php
$new_date_str = preg_replace('\s\(.*\)','',$_POST['your_js_date']);
$new_date = strtotime($new_date_str);
?>
这可能会有所帮助:)
不隶属于 StackOverflow