如何使用此格式格式化php日期

时间:2014-12-09 09:20:57

标签: php

我想使用php ...

按以下格式转换日期
2014-12-09T18:30:00.000Z

我们称这种时间格式为何?

如何将任何日期格式化为此格式?

请建议,谢谢

1 个答案:

答案 0 :(得分:0)

我认为这就是你想要的:

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

编辑:

时区

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

2002-09-24Z

日期时间数据类型

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

dateTime以下列形式指定:“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