如何使用这种格式格式化 php 日期


How to format php date using this format

我想使用 php 将日期转换为以下格式...

2014-12-09T18:30:00.000Z

我们怎么称呼这种类型的时间格式?

如何将任何日期格式化为这种格式?

请建议,谢谢

我认为这就是你想要的:

$date->format('Y-m-d'TH:i:s'Z');

编辑:

时区

要指定时区,您可以通过在日期后面添加"Z"来输入 UTC 时间的日期 - 如下所示:

2002-09-24Z

日期时间数据类型

日期时间数据类型用于指定日期和时间。

日期时间以以下形式"YYYY-MM-DDThh:mm:ss"指定,其中:

YYYY indicates the year
MM indicates the month
DD indicates the day
T indicates the start of the required time section
hh indicates the hour
mm indicates the minute
ss indicates the second