How to convert ISO8601 to Date format in php

后端 未结 4 1693
耶瑟儿~
耶瑟儿~ 2020-11-30 07:54

How to convert this (in ISO8601 format): 2014-03-13T09:05:50.240Z

To this (in MySQL DATE format): 2014-03-13

4条回答
  •  一整个雨季
    2020-11-30 08:18

    Since PHP 5.2.0 you can do it using OOP and DateTime() as well (of course if you prefer OOP):

    $now = new DateTime("2014-03-13T09:05:50.240Z");
    echo $now->format('Y-m-d');    // MySQL datetime format
    

提交回复
热议问题