3v4l.org

run code in 300+ PHP versions simultaneously
<?php $h = '2015-07-20 20:00:00'; $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
Warning: Undefined variable $defaultTimeZone in /in/gjkm3 on line 6 Fatal error: Uncaught TypeError: DateTimeImmutable::setTimezone(): Argument #1 ($timezone) must be of type DateTimeZone, null given in /in/gjkm3:6 Stack trace: #0 /in/gjkm3(6): DateTimeImmutable->setTimezone(NULL) #1 {main} thrown in /in/gjkm3 on line 6
Process exited with code 255.
Output for 7.3.16 - 7.3.31, 7.4.0 - 7.4.33
Notice: Undefined variable: defaultTimeZone in /in/gjkm3 on line 6 Warning: DateTimeImmutable::setTimezone() expects parameter 1 to be DateTimeZone, null given in /in/gjkm3 on line 6 Fatal error: Uncaught Error: Call to a member function format() on bool in /in/gjkm3:8 Stack trace: #0 {main} thrown in /in/gjkm3 on line 8
Process exited with code 255.
Output for 7.3.32 - 7.3.33
Warning: DateTimeImmutable::setTimezone() expects parameter 1 to be DateTimeZone, null given in /in/gjkm3 on line 6 Fatal error: Uncaught Error: Call to a member function format() on bool in /in/gjkm3:8 Stack trace: #0 {main} thrown in /in/gjkm3 on line 8
Process exited with code 255.
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.6 - 7.2.33
Notice: Undefined variable: defaultTimeZone in /in/gjkm3 on line 6 Warning: DateTimeImmutable::setTimezone() expects parameter 1 to be DateTimeZone, null given in /in/gjkm3 on line 6 Fatal error: Uncaught Error: Call to a member function format() on boolean in /in/gjkm3:8 Stack trace: #0 {main} thrown in /in/gjkm3 on line 8
Process exited with code 255.
Output for 5.6.8 - 5.6.28
Notice: Undefined variable: defaultTimeZone in /in/gjkm3 on line 6 Warning: DateTimeImmutable::setTimezone() expects parameter 1 to be DateTimeZone, null given in /in/gjkm3 on line 6 Fatal error: Call to a member function format() on boolean in /in/gjkm3 on line 8
Process exited with code 255.
Output for 5.5.24 - 5.5.35
Notice: Undefined variable: defaultTimeZone in /in/gjkm3 on line 6 Warning: DateTimeImmutable::setTimezone() expects parameter 1 to be DateTimeZone, null given in /in/gjkm3 on line 6 Fatal error: Call to a member function format() on a non-object in /in/gjkm3 on line 8
Process exited with code 255.
Output for 5.4.1 - 5.4.45
Fatal error: Class 'DateTimeImmutable' not found in /in/gjkm3 on line 5
Process exited with code 255.

preferences:
179.9 ms | 401 KiB | 225 Q