【发布时间】:2019-06-04 01:21:56
【问题描述】:
我需要将日期时间字符串格式 (2019-04-08 09:39:23) 转换为这种格式:2019-04-08T16:14:44.000Z - 这只是一个示例输出 - 我不知道T-Z 中的实际值是多少。
$t = "20190408093923"; # 2019-04-08 09:39:23
echo date("Y-m-dTH:i:sZ", strtotime($t));
echo PHP_EOL;
【问题讨论】:
-
ISO 8601 日期格式。回显日期(“c”,strtotime($t));干杯。
-
所需格式的末尾有 16:14:44.000Z。 "c" 有 +05:30
-
是的,只需使用 str_replace 将字符串中的 +05:30 替换为 .000Z