How do I convert datetime to ISO 8601 in PHP

前端 未结 5 646
悲哀的现实
悲哀的现实 2020-11-27 12:58

How do I convert my time from 2010-12-30 23:21:46 to ISO 8601 date format? (-_-;)

5条回答
  •  眼角桃花
    2020-11-27 13:43

    After PHP 5 you can use this: echo date("c"); form ISO 8601 formatted datetime.

    http://ideone.com/nD7piL

    Note for comments:

    Regarding to this, both of these expressions are valid for timezone, for basic format: ±[hh]:[mm], ±[hh][mm], or ±[hh].

    But note that, +0X:00 is correct, and +0X00 is incorrect for extended usage. So it's better to use date("c"). A similar discussion here.

提交回复
热议问题