How to format an UTC date to use the Z (Zulu) zone designator in php?

故事扮演 提交于 2019-11-27 12:20:22

No, there is no special constant for the desired format. I would use:

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

But you will have to make sure that the times you are using are really UTC to avoid interpretation errors in your application.

In order to get the UTC date in the desired format, you can use something like this:

gmdate('Y-m-d\TH:i:s\Z', $date->format('U'));
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!