Converting string to Date and DateTime

后端 未结 10 1738
伪装坚强ぢ
伪装坚强ぢ 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:28

    For first Date

    $_firstDate = date("m-d-Y", strtotime($_yourDateString));
    

    For New Date

    $_newDate = date("Y-m-d",strtotime($_yourDateString));
    

提交回复
热议问题