<?php
$a = 'MAY 05, 2001 00:54:00 AM';
echo date('Y-m-d',strtotime($a)).'<br />';
$b = 'MAY 05, 2001 05:54:00 AM';
echo date('Y-m-d',strtotime($b)).'<br />';
//MAY 05, 2001 00:54:00 AM return 1970-01-01
//MAY 05, 2001 05:54:00 AM return 2001-05-05
?>
<?php $a = ‘MAY 05, 2001 00:54:00 AM’; echo date(‘Y-m-d’,strtotime($a)).'<br />’; $b = ‘MAY
Share
The
AMimplies you are using a 12-hour clock. However, there is no “zero hour” in this clock system, so your first time example of00:54:00 AMis not a valid time (12-hour clock runs from one to twelve, then flips back to one with am/pm switched). Perhaps you meant just00:54:00(24-hour clock) or12:54:00 AM/PM(which would be six minutes before one o’clock).