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

前端 未结 5 1364
闹比i
闹比i 2020-12-02 17:11

I need to display and handle UTC dates in the following format:

2013-06-28T22:15:00Z

As this format is part of the ISO8601 stand

5条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-02 17:21

    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.

提交回复
热议问题