3v4l.org

run code in 300+ PHP versions simultaneously
<?php function display(\DateTimeInterface $start, \DateTimeInterface $end) { echo $start->format('Y-m-d H:i T') . ' to ' . $end->format('Y-m-d H:i T') . \PHP_EOL; $periods = new \DatePeriod($start, new \DateInterval('PT1H'), $end); $hours = iterator_count($periods); echo $hours . ' hours (iterator_count)'; echo \PHP_EOL; $diff = $end->getTimestamp() - $start->getTimestamp(); $hours = $diff / ( 60 * 60 ); echo $hours . ' hours (60 * 60)'; echo \PHP_EOL; $diff = $end->diff($start); $hours = $diff->h + ($diff->days * 24); echo $hours . ' hours (days * 24)'; } function go(\DateTimezone $tz) { date_default_timezone_set($tz->getName()); //DST starts Apr. 2nd 02:00 and moves to 03:00 display( new \DateTime('2006-04-01T12:00:00'), new \DateTime('2006-04-02T12:00:00') ); echo \PHP_EOL . \PHP_EOL; //DST ends Oct. 29th 02:00 and moves to 01:00 display( new \DateTime('2006-10-28T12:00:00'), new \DateTime('2006-10-29T12:00:00') ); echo \PHP_EOL . \PHP_EOL; //full year display( new \DateTime('2006-01-01T12:00:00'), new \DateTime('2007-01-01T12:00:00') ); } go(new \DateTimezone('America/New_York')); echo \PHP_EOL . \PHP_EOL . '---------' . \PHP_EOL . \PHP_EOL; go(new \DateTimezone('UTC'));
Output for git.master, git.master_jit, rfc.property-hooks
2006-04-01 12:00 EST to 2006-04-02 12:00 EDT 23 hours (iterator_count) 23 hours (60 * 60) 24 hours (days * 24) 2006-10-28 12:00 EDT to 2006-10-29 12:00 EST 24 hours (iterator_count) 25 hours (60 * 60) 24 hours (days * 24) 2006-01-01 12:00 EST to 2007-01-01 12:00 EST 8759 hours (iterator_count) 8760 hours (60 * 60) 8760 hours (days * 24) --------- 2006-04-01 12:00 UTC to 2006-04-02 12:00 UTC 24 hours (iterator_count) 24 hours (60 * 60) 24 hours (days * 24) 2006-10-28 12:00 UTC to 2006-10-29 12:00 UTC 24 hours (iterator_count) 24 hours (60 * 60) 24 hours (days * 24) 2006-01-01 12:00 UTC to 2007-01-01 12:00 UTC 8760 hours (iterator_count) 8760 hours (60 * 60) 8760 hours (days * 24)

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:
57.6 ms | 402 KiB | 8 Q