3v4l.org

run code in 300+ PHP versions simultaneously
<?php function incrementWithSwitch($date, $invert) { $timezone = $date->getTimezone(); $date = $date->setTimezone(new DateTimeZone('UTC')); $date = $date->modify(($invert ? '-' : '+') . '1 hour'); $date = $date->setTimezone($timezone); $date = $date->setTime((int)$date->format('H'), 0); return $date; } function incrementWithoutSwitch($date, $invert) { $date = $date->modify(($invert ? '-' : '+') . '1 hour'); return $date; } $tz = new \DateTimeZone("Europe/London"); $dtWith = \DateTimeImmutable::createFromFormat("!Y-m-d H:i:s", "2021-03-28 04:00:00"); $dtWithout = $dtWith; $invert = true; for ($i = 0; $i < 3; $i++) { print "\nRound {$i}:"; $dtWith = incrementWithSwitch($dtWith, $invert); $dtWithout = incrementWithoutSwitch($dtWithout, $invert); print "With switch: ". $dtWith->format(\DateTime::RFC3339); print " :: Without switch: ". $dtWithout->format(\DateTime::RFC3339); } print "\n---\n"; $dtWith = \DateTimeImmutable::createFromFormat("!Y-m-d H:i:s", "2021-03-28 00:00:00"); $dtWithout = $dtWith; $invert = false; for ($i = 0; $i < 3; $i++) { print "\nRound {$i}:"; $dtWith = incrementWithSwitch($dtWith, $invert); $dtWithout = incrementWithoutSwitch($dtWithout, $invert); print "With switch: ". $dtWith->format(\DateTime::RFC3339); print " :: Without switch: ". $dtWithout->format(\DateTime::RFC3339); }
Output for git.master, git.master_jit, rfc.property-hooks
Round 0:With switch: 2021-03-28T03:00:00+02:00 :: Without switch: 2021-03-28T03:00:00+02:00 Round 1:With switch: 2021-03-28T01:00:00+01:00 :: Without switch: 2021-03-28T03:00:00+02:00 Round 2:With switch: 2021-03-28T00:00:00+01:00 :: Without switch: 2021-03-28T03:00:00+02:00 --- Round 0:With switch: 2021-03-28T01:00:00+01:00 :: Without switch: 2021-03-28T01:00:00+01:00 Round 1:With switch: 2021-03-28T03:00:00+02:00 :: Without switch: 2021-03-28T03:00:00+02:00 Round 2:With switch: 2021-03-28T04:00:00+02:00 :: Without switch: 2021-03-28T04:00:00+02:00

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
56.19 ms | 402 KiB | 8 Q