duanhuihui2705 2011-03-16 07:38
浏览 159
已采纳

如何在PHP中将datetime转换为ISO 8601

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

  • 写回答

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'));
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?