I have been using the following code for a couple of months and it's been working fine, but now seems to have an issue with a certain time or time range. I have a GPS tracker that sends it's date/time like this: 150102235335
The format is ymdhis
$input_array[6] = 150102235335;
$datetime = DateTime::createFromFormat('ymdhis', $input_array[6]);
$datetime = $datetime->format('Y-m-d h:i:s');
Using that time, php crashes with the following error: PHP Fatal error: Call to a member function format() on a non-object
It seems that datetime ends up empty. However, using the time 150103004933 works just fine.
Can anyone see where I have gone wrong here, or is this a bug? Is there a better way to accomplish my date conversion? I am using PHP 5.4.35