Converting string to Date and DateTime

后端 未结 10 1640
伪装坚强ぢ
伪装坚强ぢ 2020-11-22 17:07

If I have a PHP string in the format of mm-dd-YYYY (for example, 10-16-2003), how do I properly convert that to a Date and then a DateTime

10条回答
  •  伪装坚强ぢ
    2020-11-22 17:49

    to create date from any string use:
    $date = DateTime::createFromFormat('d-m-y H:i', '01-01-01 01:00'); echo $date->format('Y-m-d H:i');

提交回复
热议问题