3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MyDateTime extends \DateTime { public function add(DateInterval $interval) { $oldDay = (int)$this->format('d'); $this->setDate((int)$this->format('Y'), (int)$this->format('m'), 1); parent::add($interval); $maxDay = (int)$this->format('t'); if($oldDay > $maxDay){ $this->setDate((int)$this->format('Y'), (int)$this->format('m'), $maxDay); } else { $this->setDate((int)$this->format('Y'), (int)$this->format('m'), $oldDay); } return $this; } public function sub(DateInterval $interval) { $oldDay = (int)$this->format('d'); $this->setDate((int)$this->format('Y'), (int)$this->format('m'), 1); parent::sub($interval); $maxDay = (int)$this->format('t'); if($oldDay > $maxDay){ $this->setDate((int)$this->format('Y'), (int)$this->format('m'), $maxDay); } else { $this->setDate((int)$this->format('Y'), (int)$this->format('m'), $oldDay); } return $this; } } $myDateTime = new MyDateTime('30th November 2012'); $interval = new \DateInterval('P3M'); var_dump($myDateTime->add($interval))

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
5.4.170.0070.04412.42
5.4.160.0120.04812.41
5.4.150.0100.04012.41
5.4.140.0120.04212.10
5.4.130.0090.03912.08
5.4.120.0080.04012.04
5.4.110.0090.04512.04
5.4.100.0120.04112.04
5.4.90.0090.04512.04
5.4.80.0110.04412.04
5.4.70.0100.04212.03
5.4.60.0100.04412.04
5.4.50.0110.04312.04
5.4.40.0100.04212.02
5.4.30.0100.04112.02
5.4.20.0090.04312.01
5.4.10.0100.04212.02
5.4.00.0110.04011.51
5.3.270.0140.05912.72
5.3.260.0110.04312.72
5.3.250.0100.04312.72
5.3.240.0100.04412.72
5.3.230.0110.04012.71
5.3.220.0100.04112.68
5.3.210.0120.04012.68
5.3.200.0090.04112.68
5.3.190.0080.04212.68
5.3.180.0120.04812.68
5.3.170.0110.04012.68
5.3.160.0120.04112.68
5.3.150.0100.04412.68
5.3.140.0130.04312.67
5.3.130.0110.04312.67
5.3.120.0110.04612.67
5.3.110.0090.04612.67
5.3.100.0120.04412.15
5.3.90.0130.05512.13
5.3.80.0110.04312.12
5.3.70.0120.04312.12
5.3.60.0100.04612.11
5.3.50.0140.05312.06
5.3.40.0100.04412.05
5.3.30.0130.04012.02
5.3.20.0080.04411.80
5.3.10.0110.04011.76
5.3.00.0140.04711.75

preferences:
140.54 ms | 1386 KiB | 7 Q