Running PHP 5.3.28
I have a particular date getting returned as a string that strtotime is choking on, so I thought to try out DateTime::createFromFormat(), however despite best efforts getting errors.
<?php
$freshdate = '09/07/2015 (Mon)';
$date = DateTime::createFromFormat("m/d/Y (D)", $freshdate);
if (!$date) {
var_dump('error', DateTime::getLastErrors());
}
Result is:
array (size=4)
'warning_count' => int 0
'warnings' => array (size=0)
'error_count' => int 2
'errors' => array (size=2)
12 => string 'A textual day could not be found' (length=32)
16 => string 'Data missing' (length=12)
This is bug in PHP#65554:
createFromFormat fails when in the format D or l is followed by separators that are not space or comma.
How to fix? Change your format or upgrade your PHP version.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With