我想在PHP
中将字符串转换为日期。我收到的字符串格式如下:
"2016-07-16T1:22:04.324+1030"
或者
"2016-12-20T03:24:59.000Z"
当我尝试这个时,
$newDate = DateTime::createFromFormat("c", $exp);
$expirationDate = $newFormat->getTimestamp();
DateTime
出现了错误。即使我尝试进行调整。
$newDate = DateTime::createFromFormat(ISO8601, $exp;
$expirationDate = $newFormat->getTimestamp();
DateTime
仍然失败。
如有建议,不胜感激。
YYYY-MM-DDThh:mm:ss[.sss]
。因此,您的字符串不是ISO861。 - Sergey Khalitov