如何转换(ISO8601 格式): 2014-03-13T09:05:50.240Z
为此(采用 MySQL DATE 格式): 2014-03-13
在 PHP 中?
最佳答案
试试这个
$date = '2014-03-13T09:05:50.240Z';
$fixed = date('Y-m-d', strtotime($date));
完整的日期函数文档可以在这里找到:http://php.net/manual/en/function.date.php
PHP 函数“strtotime”只是将您的时间字符串转换为 unix 时间戳。
希望我能帮上忙:)
附言: 以防万一 strtotime 将返回 0 尝试使用此:
$date = '2014-03-13T09:05:50.240Z';
$fixed = date('Y-m-d', strtotime(substr($date,0,10)));
关于php - 如何在php中将ISO8601转换为日期格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22376415/