<?php
$tests = [
"February 13 2022 10:08 PM",
"March 23 2022 00:20 AM",
"April 3 2022 11:20 PM",
"May 28 2022 12:20 AM",
"June 12 2022 21:20 PM",
"July 4 2022 13:20 AM",
];
$tests = preg_replace(
[
'/(?:0\d|1[01]):\d{2}\K AM/',
'/(?:2\d|1[3-9]):\d{2}\K [AP]M/',
],
'',
$tests
);
var_export($tests);
foreach ($tests as $test) {
echo date('Y-m-d H:i:s', strtotime($test)) . "\n";
}
- Output for 8.0.1 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
- array (
0 => 'February 13 2022 10:08 PM',
1 => 'March 23 2022 00:20',
2 => 'April 3 2022 11:20 PM',
3 => 'May 28 2022 12:20 AM',
4 => 'June 12 2022 21:20',
5 => 'July 4 2022 13:20',
)2022-02-13 22:08:00
2022-03-23 00:20:00
2022-04-03 23:20:00
2022-05-28 00:20:00
2022-06-12 21:20:00
2022-07-04 13:20:00
preferences:
129.57 ms | 403 KiB | 91 Q