Correct input values of strtotime

前端 未结 3 738
自闭症患者
自闭症患者 2021-01-26 11:17

I want to convert a date by the following statement

$date=date(\'d M Y, H:m\',strtotime($date));

It printed out 09 Sep 2012, 11:09

3条回答
  •  生来不讨喜
    2021-01-26 11:23

    Looks like the only way to go is to sort the elements in proper order by regular expressions and then replace the month name by corresponding number. Such a string strtotime will manage. Note: I'm talking about PHP 5.2x

    EDIT: I found the reason, why strtotime "wasn't working" was that I made a typo in the date formating string, there should be 'd M Y, H:i'

提交回复
热议问题