简体   繁体   English

这是什么日期格式? 2021-10-04T08:19:54.000+04:00

[英]What is this date format? 2021-10-04T08:19:54.000+04:00

And how can I covert it to 'dmY H:i:s' with php?以及如何使用 php 将其转换为“dmY H:i:s”?

gmdate('d.m.Y H:i:s', '2021-10-04T08:19:54.000+04:00')

did not help没有帮助

The date format is ISO8601 if I'm not mistaken.如果我没记错的话,日期格式是 ISO8601。 PHP can parse this using the default DateTime class: PHP 可以使用默认的DateTime类来解析它:

$date = new DateTime('2021-10-04T08:19:54.000+04:00');
$date->format('d.m.Y H:i:s');

For this purpose just use the native DateTime class.为此,只需使用本机DateTime类。 It can interpret several formats.它可以解释多种格式。 Yours looks like ISO8601.你的看起来像 ISO8601。

echo (new DateTime('2021-10-04T08:19:54.000+04:00'))->format('d.m.Y H:i:s');

its ISO 8601 date and you can format this easyly with dateTime or carbon.它的 ISO 8601 日期,您可以使用 dateTime 或 carbon 轻松格式化它。 You can find more info here https://www.php.net/manual/en/datetime.format.php您可以在此处找到更多信息https://www.php.net/manual/en/datetime.format.php

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM