$format = 'd M Y A h:i';
$date = DateTime::createFromFormat($format, '11 Mar 2013 PM 3:34');
Returns false. getLastErrors returs:
[errors] => Array ( [12] => Unexpected data found. )
After removing A in format and PM in date it started to work.
$format = 'd M Y h:i';
$date = DateTime::createFromFormat($format, '11 Mar 2013 3:34');
Any solution how to make it working with AM and PM ?
I would append the AM/PM after the time. See http://php.net/manual/en/datetime.formats.time.php for accepted time formats.
来源:https://stackoverflow.com/questions/16936979/php-datetimecreatefromformat-am-pm-issue