3v4l.org

run code in 300+ PHP versions simultaneously
<?php //Tinker away! $dateString = "4 Квітень 2009"; $dateString = "Wednesday 22nd of May 2024 05:33:36 PM"; date_default_timezone_set('UTC'); // сейчас $date = new DateTimeImmutable($dateString); // Выведет что-то подобное: Wednesday echo $date->format('l'), "\n"; // Выведет что-то подобное: Wednesday 19th of October 2022 08:40:48 AM echo $date->format('l jS \o\f F Y h:i:s A'), "\n"; /* Использование констант в параметре format */ // Выведет что-то подобное: Wed, 19 Oct 2022 08:40:48 +0000 echo $date->format(DateTimeInterface::RFC2822), "\n";
Output for 8.3.0 - 8.3.8
Fatal error: Uncaught DateMalformedStringException: Failed to parse time string (Wednesday 22nd of May 2024 05:33:36 PM) at position 10 (2): Unexpected character in /in/25mFh:9 Stack trace: #0 /in/25mFh(9): DateTimeImmutable->__construct('Wednesday 22nd ...') #1 {main} thrown in /in/25mFh on line 9
Process exited with code 255.
Output for 8.1.0 - 8.1.29, 8.2.0 - 8.2.20
Fatal error: Uncaught Exception: Failed to parse time string (Wednesday 22nd of May 2024 05:33:36 PM) at position 10 (2): Unexpected character in /in/25mFh:9 Stack trace: #0 /in/25mFh(9): DateTimeImmutable->__construct('Wednesday 22nd ...') #1 {main} thrown in /in/25mFh on line 9
Process exited with code 255.

preferences:
70.11 ms | 402 KiB | 65 Q