3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MyDateInterval extends DateInterval { /** * @return MyDateInterval */ public static function fromDateInterval(DateInterval $from) { return new MyDateInterval($from->format('P%yY%dDT%hH%iM%sS')); } public function add(DateInterval $interval) { foreach (str_split('ymdhis') as $prop) { $this->$prop += $interval->$prop; } } } $a = new DateTime('14:25'); $b = new DateTime('17:30'); $interval1 = $a->diff($b); echo "interval 1: ", $interval1->format("%H:%I"), "\n"; $c = new DateTime('08:00'); $d = new DateTime('13:00'); $interval2 = $c->diff($d); echo "interval 2: ", $interval2->format("%H:%I"), "\n"; $e = MyDateInterval::fromDateInterval($interval1); $e->add($interval2); echo "Total interval: ", $e->format("%H:%I"), "\n";
Output for git.master, git.master_jit, rfc.property-hooks
interval 1: 03:05 interval 2: 05:00 Total interval: 08:05

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:
139.22 ms | 405 KiB | 5 Q