我有一个API响应,它以以下格式返回时间
“时间”:“ 2019-04-26T08:44:22.283Z”
我尝试将其重新格式化以将其插入下面的代码行中的数据库中
$time = date('Y-m-d h:i:s', strtotime(date($response->Time)));
,但在数据库中另存为 1970-01-01 02:00:00
答案 0 :(得分:1)
答案 1 :(得分:0)
您可以使用DateTime类正确处理它。
echo (new DateTime("2019-04-26T08:44:22.283Z"))->format("Y-m-d H:i:s") . "\n";