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

如何在PHP中将datetime转换为ISO 8601
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
5条回答 默认 最新
- duanqiu2064 2011-03-16 07:42关注
Object Oriented
This is the recommended way.
$datetime = new DateTime('2010-12-30 23:21:46'); echo $datetime->format(DateTime::ATOM); // Updated ISO8601
Procedural
For older versions of PHP, or if you are more comfortable with procedural code.
echo date(DATE_ISO8601, strtotime('2010-12-30 23:21:46'));
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报