3v4l.org

run code in 300+ PHP versions simultaneously
<?php function test_timezone1(string $timezone) : string { $fmt = new IntlDateFormatter('en_US.utf8'); $res = $fmt->setTimeZone(new DateTimeZone($timezone)); if ($res === false) { var_dump($fmt->getErrorMessage()); } $fmt->setPattern('yyyy-MM-dd HH:mm'); return $fmt->format(time()); } var_dump(test_timezone1('Europe/Kiev')); var_dump(test_timezone1('Europe/Kyiv'));
Output for 8.1.10 - 8.1.27, 8.2.0 - 8.2.24, 8.3.0 - 8.3.7
string(16) "2024-01-15 18:44" string(126) "datefmt_set_timezone: time zone id 'Europe/Kyiv' extracted from ext/date DateTimeZone not recognized: U_ILLEGAL_ARGUMENT_ERROR" string(16) "2024-01-15 17:44"
Output for 8.1.0 - 8.1.9
string(16) "2024-01-15 18:44" Fatal error: Uncaught Exception: DateTimeZone::__construct(): Unknown or bad timezone (Europe/Kyiv) in /in/3A9uc:6 Stack trace: #0 /in/3A9uc(6): DateTimeZone->__construct('Europe/Kyiv') #1 /in/3A9uc(15): test_timezone1('Europe/Kyiv') #2 {main} thrown in /in/3A9uc on line 6
Process exited with code 255.
Output for 8.0.1 - 8.0.30
Fatal error: Uncaught ArgumentCountError: IntlDateFormatter::__construct() expects at least 3 arguments, 1 given in /in/3A9uc:5 Stack trace: #0 /in/3A9uc(5): IntlDateFormatter->__construct('en_US.utf8') #1 /in/3A9uc(14): test_timezone1('Europe/Kiev') #2 {main} thrown in /in/3A9uc on line 5
Process exited with code 255.
Output for 7.4.33
Fatal error: Uncaught Error: Class 'IntlDateFormatter' not found in /in/3A9uc:5 Stack trace: #0 /in/3A9uc(14): test_timezone1('Europe/Kiev') #1 {main} thrown in /in/3A9uc on line 5
Process exited with code 255.
Output for 7.3.33, 7.4.0 - 7.4.32
Fatal error: Uncaught ArgumentCountError: IntlDateFormatter::__construct() expects at least 3 parameters, 1 given in /in/3A9uc:5 Stack trace: #0 /in/3A9uc(5): IntlDateFormatter->__construct('en_US.utf8') #1 /in/3A9uc(14): test_timezone1('Europe/Kiev') #2 {main} thrown in /in/3A9uc on line 5
Process exited with code 255.

preferences:
88.72 ms | 412 KiB | 5 Q