I used date() to convert 12H time to 24H using this code
$over = date("Y-m-d H:i:s", strtotime("2021-12-16 13:42:46 PM"));
echo $over;
but the output is this below:
1969-12-31 16:00:00
How to get rid of this, is this a bug? or my code?
CodePudding user response:
13:42:46 PM isn't 12h time format (PM is nonsense in 24h format), 01:42:46 PM is correct.
CodePudding user response:
Just specify the correct date format (PM
is not supported):
$over = date("Y-m-d H:i:s", strtotime("2021-12-16 13:42:46"));
echo $over;
Which date format is supported you can find in https://www.php.net/manual/de/datetime.formats.php