我收到这个错误
(!)致命错误:带有消息'DateTime :: __ construct()的未捕获异常'Exception':无法解析位置0(0)处的时间字符串(06-28-2014 07:43:58):/中的意外字符用户/ matt /桌面/喜欢/忘记/ activate.php在第17行
当试图这样做
//DB query
$stmt = $con->prepare("SELECT token_created_at from reset WHERE token = :urltoken");
$stmt->bindValue(':urltoken', $_GET['token']);
$stmt->execute();
$stmt->setFetchMode(PDO::FETCH_ASSOC);
while($row = $stmt->fetch()) {
$token_created_at = $row['token_created_at'];
}
//Remove after testing
echo $token_created_at;
$my_dt = new DateTime($token_created_at);
//Modify error
$expires_at = $my_dt->modify('+1 hour');
//Return current time to match
$current_time = date('m-d-Y H:i:s ', time());
Run Code Online (Sandbox Code Playgroud)
第17行是$my_dt = new DateTime($token_created_at);,这是我的时间格式06-28-2014 07:43:58.
我就是这样产生token_created_at,$time_gen = date('m-d-Y H:i:s ', time());.
BRST指"巴西利亚夏令时"
在7.0.26版之前,PHP可以解析此字符串而不会出现任何问题:
$date = DateTime("Mon Jan 01 20:00:00 BRST 2017");
Run Code Online (Sandbox Code Playgroud)
在该版本之后,PHP返回:
Fatal error: Uncaught Exception: DateTime::__construct(): Failed to
parse time string (Mon Jan 01 20:00:00 BRST 2017) at position 4 (J):
The timezone could not be found in the database in /in/c6K56:5
Stack trace:
#0 /in/c6K56(5): DateTime->__construct('Mon Jan 01 20:0...')
#1 {main}
thrown in /in/c6K56 on line 5
Process exited with code 255.
Run Code Online (Sandbox Code Playgroud)
我搜索了更改日志,但我找不到任何解释.
这是一个例子: