3v4l.org

run code in 300+ PHP versions simultaneously
<?php $dt = new DateTime('2018-10-28 02:00:00', new DateTimeZone('Europe/Prague')); //Transition local time 3:00 to 2:00 $d = $dt->format('Y-m-d H:i:s P T'); $time = $dt->format('U'); $dt2 = new DateTime('@'.$time); $d2 = $dt2->format('Y-m-d H:i:s P T'); $tz = $dt->getTimezone(); $e = $tz->getTransitions($time, $time); $dt3 = clone $dt; $date1 = $dt3->setTimestamp($time - 1); $dt3 = clone $dt; $date2 = $dt3->setTimestamp($time); $dt3 = clone $dt; $date3 = $dt3->setTimestamp($time + 3600 - 1); $dt3 = clone $dt; $date4 = $dt3->setTimestamp($time + 3600); $dt3 = clone $dt; $date5 = $dt3->setTimestamp($time + 3600*2 - 1); $dt3 = clone $dt; var_dump($date1->format(DateTime::ATOM)); var_dump($date2->format(DateTime::ATOM)); var_dump($date3->format(DateTime::ATOM)); var_dump($date4->format(DateTime::ATOM)); var_dump($date5->format(DateTime::ATOM)); var_dump('Europe/Prague '.$d, 'UTC '.$d2, $e);
Output for 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
string(25) "2018-10-28T02:59:59+02:00" string(25) "2018-10-28T02:00:00+01:00" string(25) "2018-10-28T02:59:59+01:00" string(25) "2018-10-28T03:00:00+01:00" string(25) "2018-10-28T03:59:59+01:00" string(44) "Europe/Prague 2018-10-28 02:00:00 +01:00 CET" string(39) "UTC 2018-10-28 01:00:00 +00:00 GMT+0000" array(2) { [0]=> array(5) { ["ts"]=> int(1540688400) ["time"]=> string(25) "2018-10-28T01:00:00+00:00" ["offset"]=> int(3600) ["isdst"]=> bool(false) ["abbr"]=> string(3) "CET" } [1]=> array(5) { ["ts"]=> int(1540688400) ["time"]=> string(25) "2018-10-28T01:00:00+00:00" ["offset"]=> int(3600) ["isdst"]=> bool(false) ["abbr"]=> string(3) "CET" } }
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 string(25) "2018-10-28T02:59:59+02:00" string(25) "2018-10-28T02:00:00+01:00" string(25) "2018-10-28T02:59:59+01:00" string(25) "2018-10-28T03:00:00+01:00" string(25) "2018-10-28T03:59:59+01:00" string(44) "Europe/Prague 2018-10-28 02:00:00 +01:00 CET" string(39) "UTC 2018-10-28 01:00:00 +00:00 GMT+0000" array(2) { [0]=> array(5) { ["ts"]=> int(1540688400) ["time"]=> string(25) "2018-10-28T01:00:00+00:00" ["offset"]=> int(3600) ["isdst"]=> bool(false) ["abbr"]=> string(3) "CET" } [1]=> array(5) { ["ts"]=> int(1540688400) ["time"]=> string(25) "2018-10-28T01:00:00+00:00" ["offset"]=> int(3600) ["isdst"]=> bool(false) ["abbr"]=> string(3) "CET" } }
Output for 8.1.7 - 8.1.28
string(25) "2018-10-28T02:59:59+02:00" string(25) "2018-10-28T02:00:00+01:00" string(25) "2018-10-28T02:59:59+01:00" string(25) "2018-10-28T03:00:00+01:00" string(25) "2018-10-28T03:59:59+01:00" string(44) "Europe/Prague 2018-10-28 02:00:00 +01:00 CET" string(39) "UTC 2018-10-28 01:00:00 +00:00 GMT+0000" array(2) { [0]=> array(5) { ["ts"]=> int(1540688400) ["time"]=> string(24) "2018-10-28T01:00:00+0000" ["offset"]=> int(3600) ["isdst"]=> bool(false) ["abbr"]=> string(3) "CET" } [1]=> array(5) { ["ts"]=> int(1540688400) ["time"]=> string(24) "2018-10-28T01:00:00+0000" ["offset"]=> int(3600) ["isdst"]=> bool(false) ["abbr"]=> string(3) "CET" } }
Output for 8.1.6
string(25) "2018-10-28T02:59:59+01:00" string(25) "2018-10-28T02:00:00+01:00" string(25) "2018-10-28T02:59:59+01:00" string(25) "2018-10-28T03:00:00+01:00" string(25) "2018-10-28T03:59:59+01:00" string(44) "Europe/Prague 2018-10-28 02:00:00 +01:00 CET" string(39) "UTC 2018-10-28 01:00:00 +00:00 GMT+0000" array(2) { [0]=> array(5) { ["ts"]=> int(1540688400) ["time"]=> string(24) "2018-10-28T01:00:00+0000" ["offset"]=> int(3600) ["isdst"]=> bool(false) ["abbr"]=> string(3) "CET" } [1]=> array(5) { ["ts"]=> int(1540688400) ["time"]=> string(24) "2018-10-28T01:00:00+0000" ["offset"]=> int(3600) ["isdst"]=> bool(false) ["abbr"]=> string(3) "CET" } }
Output for 8.1.0 - 8.1.5
string(25) "2018-10-28T02:59:59+01:00" string(25) "2018-10-28T02:00:00+01:00" string(25) "2018-10-28T02:59:59+01:00" string(25) "2018-10-28T03:00:00+01:00" string(25) "2018-10-28T03:59:59+01:00" string(44) "Europe/Prague 2018-10-28 02:00:00 +01:00 CET" string(39) "UTC 2018-10-28 01:00:00 +00:00 GMT+0000" array(1) { [0]=> array(5) { ["ts"]=> int(1540688400) ["time"]=> string(24) "2018-10-28T01:00:00+0000" ["offset"]=> int(7200) ["isdst"]=> bool(true) ["abbr"]=> string(4) "CEST" } }
Output for 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.34, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30
string(25) "2018-10-28T02:59:59+01:00" string(25) "2018-10-28T02:00:00+01:00" string(25) "2018-10-28T02:59:59+01:00" string(25) "2018-10-28T03:00:00+01:00" string(25) "2018-10-28T03:59:59+01:00" string(44) "Europe/Prague 2018-10-28 02:00:00 +01:00 CET" string(39) "UTC 2018-10-28 01:00:00 +00:00 GMT+0000" array(1) { [0]=> array(5) { ["ts"]=> int(1540688400) ["time"]=> string(24) "2018-10-28T01:00:00+0000" ["offset"]=> int(3600) ["isdst"]=> bool(false) ["abbr"]=> string(3) "CET" } }
Output for 5.2.0 - 5.2.17
Warning: DateTimeZone::getTransitions() expects exactly 0 parameters, 2 given in /in/CNGnE on line 9 Fatal error: Call to undefined method DateTime::setTimestamp() in /in/CNGnE on line 11
Process exited with code 255.
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6
Fatal error: Class 'DateTime' not found in /in/CNGnE on line 3
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_VARIABLE in /in/CNGnE on line 10
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1
Parse error: parse error, unexpected T_VARIABLE in /in/CNGnE on line 10
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/CNGnE on line 10
Process exited with code 255.

preferences:
399.26 ms | 401 KiB | 468 Q