PHP - format date ISO8601?

怎甘沉沦 提交于 2019-12-04 07:59:08

The 'c' format in PHP always appends the timezone offset. You can't avoid that. But you can build the date yourself from components:

date('Y-m-d\TH:i:s', $testdate);
date('Y-m-d\TH:i:s\Z', time() - date('Z'));

Best way is to use constants (PHP 5 >= 5.5.0, PHP 7)

date(DATE_ISO8601, $timeToChange);

Docs: http://php.net/manual/en/class.datetimeinterface.php#datetime.constants.types

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!