3v4l.org

run code in 500+ PHP versions simultaneously
<?php $validDateTimeStringsAccordingToIso8601 = [ '20230328T070000.000Z', // a basic format containing a microsecond fraction '2023-03-28T07:00:00.000Z', // The exact sme as extended format '20230328T07.5Z' // a basic format describing 7:30 according to ISO ]; foreach ($validDateTimeStringsAccordingToIso8601 as $dateTime) { try { $d = new DateTimeImmutable($dateTime); echo $d->format('c') . PHP_EOL; } catch (Throwable $t) { echo $t . PHP_EOL; } }
Output for 8.3.0 - 8.3.30, 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
DateMalformedStringException: Failed to parse time string (20230328T070000.000Z) at position 16 (0): Unexpected character in /in/ZJt06:11 Stack trace: #0 /in/ZJt06(11): DateTimeImmutable->__construct('20230328T070000...') #1 {main} 2023-03-28T07:00:00+00:00 2023-03-28T07:05:00+00:00
Output for 8.1.0 - 8.1.34, 8.2.0 - 8.2.30
Exception: Failed to parse time string (20230328T070000.000Z) at position 16 (0): Unexpected character in /in/ZJt06:11 Stack trace: #0 /in/ZJt06(11): DateTimeImmutable->__construct('20230328T070000...') #1 {main} 2023-03-28T07:00:00+00:00 2023-03-28T07:05:00+00:00
Output for 8.0.1 - 8.0.30
Exception: DateTimeImmutable::__construct(): Failed to parse time string (20230328T070000.000Z) at position 16 (0): Unexpected character in /in/ZJt06:11 Stack trace: #0 /in/ZJt06(11): DateTimeImmutable->__construct('20230328T070000...') #1 {main} 2023-03-28T07:00:00+00:00 2023-03-28T07:05:00+00:00

preferences:
99.08 ms | 1146 KiB | 4 Q