Correct input values of strtotime

前端 未结 3 742
自闭症患者
自闭症患者 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:41

    From this site (http://www.tuxradar.com/practicalphp/4/5/2)

    Be wary of dates such as this one: August 25, 2003, 10:26am. Although this may look perfectly well-formed, strtotime() is not able to handle it because it has commas in there - yes, they make it much more readable for us, but strtotime() gets confused handling them. If you have dates with commas in, be sure to strip them out using str_replace().

    How to deal with strtotime() -> http://www.w3schools.com/php/func_date_strtotime.asp

提交回复
热议问题