3v4l.org

run code in 300+ PHP versions simultaneously
<?php date_default_timezone_set('Europe/Madrid'); $start = new DateTime('2017-03-26 01:59:00'); $increments = array( '+60 minutes' => '2017-03-26 03:59:00', '+61 minutes' => '2017-03-26 04:00:00', ); echo 'Start: ' . $start->format('r') . PHP_EOL; $local = $start->getTimezone(); $utc = new DateTimeZone('UTC'); foreach ($increments as $increment => $expected_string) { echo '>>> ' . $increment . PHP_EOL; $expected_end = new DateTime($expected_string); $actual_end = clone $start; $actual_end->setTimezone($utc); $actual_end->modify($increment); $actual_end->setTimezone($local); echo 'Expected end: ' . $expected_end->format('r') . PHP_EOL; echo 'Actual end: ' . $actual_end->format('r') . PHP_EOL; echo ($expected_end->format('c')===$actual_end->format('c') ? 'OK' : 'ERROR') . PHP_EOL; echo PHP_EOL; }
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
Start: Sun, 26 Mar 2017 01:59:00 +0100 >>> +60 minutes Expected end: Sun, 26 Mar 2017 03:59:00 +0200 Actual end: Sun, 26 Mar 2017 03:59:00 +0200 OK >>> +61 minutes Expected end: Sun, 26 Mar 2017 04:00:00 +0200 Actual end: Sun, 26 Mar 2017 04:00:00 +0200 OK
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 Start: Sun, 26 Mar 2017 01:59:00 +0100 >>> +60 minutes Expected end: Sun, 26 Mar 2017 03:59:00 +0200 Actual end: Sun, 26 Mar 2017 03:59:00 +0200 OK >>> +61 minutes Expected end: Sun, 26 Mar 2017 04:00:00 +0200 Actual end: Sun, 26 Mar 2017 04:00:00 +0200 OK

preferences:
183.75 ms | 402 KiB | 214 Q