strtotime() and DateTime::createFromFormat return wrong date
and
date('m/d/y H:i A', strtotime('09/29/2018 4:15 PM'))
return me 09/29/18 16:15 PM
Why is that, and how to fix it?
strtotime() and DateTime::createFromFormat return wrong date
and
date('m/d/y H:i A', strtotime('09/29/2018 4:15 PM'))
return me 09/29/18 16:15 PM
Why is that, and how to fix it?
Use i for minute
$date = DateTime::createFromFormat('m/d/y H:i A', '09/30/18 10:00 AM');
You need to use i instead of m for month.
In addition, you need to use h instead of H, to show the hours in the 12 hours format.
$date = DateTime::createFromFormat('m/d/y h:i A', '09/30/18 10:00 AM');
echo $date->format('m/d/y h:i');
As you can see, m is already used for the month, so if you would have looked to the php.net documentation, you would have found that there are different letters for the hours.