3v4l.org

run code in 300+ PHP versions simultaneously
<?php $h = '2015-07-20 20:00:00'; $defaultTimeZone = new DateTimeImmutable('now', 'EET'); $defaultTimeZone = $defaultTimeZone->getTimezone(); $df = new DateTimeImmutable($h, new DateTimeZone('UTC')); $df = $df->setTimezone($defaultTimeZone); $eh = (int) $df->format('H'); var_dump($df);
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Fatal error: Uncaught TypeError: DateTimeImmutable::__construct(): Argument #2 ($timezone) must be of type ?DateTimeZone, string given in /in/Kfab4:5 Stack trace: #0 /in/Kfab4(5): DateTimeImmutable->__construct('now', 'EET') #1 {main} thrown in /in/Kfab4 on line 5
Process exited with code 255.
Output for 7.0.0 - 7.0.32, 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
Fatal error: Uncaught TypeError: DateTimeImmutable::__construct() expects parameter 2 to be DateTimeZone, string given in /in/Kfab4:5 Stack trace: #0 /in/Kfab4(5): DateTimeImmutable->__construct('now', 'EET') #1 {main} thrown in /in/Kfab4 on line 5
Process exited with code 255.
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.38
Fatal error: Uncaught exception 'Exception' with message 'DateTimeImmutable::__construct() expects parameter 2 to be DateTimeZone, string given' in /in/Kfab4:5 Stack trace: #0 /in/Kfab4(5): DateTimeImmutable->__construct('now', 'EET') #1 {main} thrown in /in/Kfab4 on line 5
Process exited with code 255.
Output for 5.4.0 - 5.4.45
Fatal error: Class 'DateTimeImmutable' not found in /in/Kfab4 on line 5
Process exited with code 255.

preferences:
243.98 ms | 401 KiB | 339 Q