3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MyDateTime extends \DateTime { public function add($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($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; } public function diff($dateTime2, $absolute = false) { if((int)$this->format('t') > (int)$dateTime2->format('t')){ $this->setDate((int)$this->format('Y'), (int)$this->format('m'), (int)$dateTime2->format('t')); } if((int)$this->format('t') < (int)$dateTime2->format('t')){ $dateTime2->setDate((int)$dateTime2->format('Y'), (int)$dateTime2->format('m'), (int)$this->format('t')); } return parent::diff($dateTime2, $absolute); } } $myDateTime1 = new MyDateTime('30th November 2012'); $myDateTime2 = new MyDateTime('28th February 2013'); $interval = $myDateTime2->diff($myDateTime1, true); var_dump($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)
8.0.110.0000.00917.11
8.0.100.0050.00317.04
8.0.90.0000.00716.95
8.0.80.0070.00717.02
8.0.70.0030.00516.95
8.0.60.0040.00417.12
8.0.50.0040.00416.93
8.0.30.0050.01517.28
8.0.20.0120.00917.21
8.0.10.0030.00517.30
8.0.00.0130.00716.95
7.4.240.0000.00716.68
7.4.230.0030.00316.64
7.4.220.0100.01016.64
7.4.210.0080.01216.73
7.4.200.0040.00416.57
7.4.190.0030.00316.94
7.4.160.0030.01216.66
7.4.150.0060.01316.65
7.4.140.0060.01216.68
7.4.130.0080.01216.59
7.4.120.0070.01116.58
7.4.110.0160.00316.77
7.4.100.0070.01116.67
7.4.90.0070.01016.75
7.4.80.0090.00916.90
7.4.70.0030.01316.84
7.4.60.0080.01016.61
7.4.50.0000.00616.69
7.4.40.0100.00316.71
7.4.30.0080.00816.92
7.4.00.0040.01315.21
7.3.300.0060.00016.36
7.3.290.0080.00816.46
7.3.280.0060.01216.45
7.3.270.0190.00316.66
7.3.260.0100.00916.55
7.3.250.0130.00516.60
7.3.240.0100.00716.63
7.3.230.0180.00316.71
7.3.210.0180.00016.55
7.3.200.0030.01719.39
7.3.190.0110.00716.77
7.3.180.0080.00816.56
7.3.170.0190.00316.63
7.3.160.0060.01016.67
7.3.120.0060.01014.87
7.3.110.0060.01214.95
7.3.100.0090.00615.15
7.3.90.0040.00414.93
7.3.80.0000.01114.89
7.3.70.0030.00714.94
7.3.60.0000.01114.91
7.3.50.0090.00614.92
7.3.40.0030.00614.91
7.3.30.0060.00514.74
7.3.20.0120.00316.76
7.3.10.0050.00716.76
7.3.00.0040.01016.71
7.2.330.0030.01616.69
7.2.320.0140.01116.76
7.2.310.0100.01116.66
7.2.300.0070.01016.58
7.2.290.0130.00316.99
7.2.250.0030.01615.02
7.2.240.0140.00715.41
7.2.230.0060.00615.32
7.2.220.0040.01115.20
7.2.210.0040.01515.17
7.2.200.0110.00715.18
7.2.190.0030.01015.01
7.2.180.0040.01115.26
7.2.170.0000.01215.25
7.2.130.0080.00717.02
7.2.120.0050.01016.81
7.2.110.0070.00917.02
7.2.100.0100.00616.95
7.2.90.0070.00816.95
7.2.80.0070.00616.81
7.2.70.0070.00816.97
7.2.60.0080.00716.97
7.2.50.0050.00717.02
7.2.40.0090.00716.93
7.2.30.0100.00616.93
7.2.20.0050.00917.09
7.2.10.0100.00617.08
7.2.00.0090.00716.86
7.1.330.0040.01115.75
7.1.320.0090.00315.96
7.1.310.0100.00315.80
7.1.300.0090.00616.02
7.1.290.0110.00315.79
7.1.280.0030.00716.00
7.1.270.0000.00815.92
7.1.260.0070.01015.98
7.1.250.0110.00415.97
7.1.200.0040.00415.59
7.1.100.0200.00718.09
7.1.70.0050.00217.36
7.1.60.0030.01719.40
7.1.50.0070.01417.11
7.1.00.0000.07322.51
7.0.200.0170.00315.00
7.0.140.0100.06721.92
7.0.120.0030.07322.13
7.0.60.0230.06321.75
7.0.50.0100.03317.88
7.0.40.0130.03320.26
7.0.30.0130.03320.23
7.0.20.0030.04320.16
7.0.10.0030.04720.23
7.0.00.0100.03720.02
5.6.280.0100.06720.95
5.6.210.0030.05320.49
5.6.200.0170.07318.19
5.6.190.0070.04020.64
5.6.180.0030.04320.47
5.6.170.0000.04320.39
5.6.160.0200.03320.52
5.6.150.0100.03720.23
5.6.140.0030.04020.38
5.6.130.0070.05020.49
5.6.120.0030.04020.41
5.6.110.0030.04020.24
5.6.100.0070.04020.36
5.6.90.0000.04720.48
5.6.80.0070.03719.72
5.6.70.0130.06319.61
5.6.60.0070.05019.56
5.6.50.0130.05719.58
5.6.40.0100.05019.88
5.6.30.0130.07319.85
5.6.20.0000.05019.53
5.6.10.0070.05019.73
5.6.00.0070.06019.69
5.5.350.0130.06720.42
5.5.340.0070.03717.97
5.5.330.0070.03720.31
5.5.320.0030.04020.21
5.5.310.0030.04020.19
5.5.300.0070.04020.12
5.5.290.0070.04020.14
5.5.280.0070.04320.15
5.5.270.0100.03320.20
5.5.260.0100.03319.96
5.5.250.0000.04320.04
5.5.240.0030.04019.52
5.5.230.0100.04319.50
5.5.220.0100.08019.51
5.5.210.0030.06719.68
5.5.200.0030.08719.47
5.5.190.0070.04319.64
5.5.180.0100.07719.52
5.5.160.0100.04019.58
5.5.150.0070.08019.64
5.5.140.0070.04019.67
5.5.130.0070.08019.31
5.5.120.0000.07019.50
5.5.110.0130.03019.66
5.5.100.0070.06719.28
5.5.90.0070.06719.55
5.5.80.0070.07319.21
5.5.70.0000.08319.45
5.5.60.0030.04019.27
5.5.50.0130.07719.38
5.5.40.0100.05719.46
5.5.30.0070.05019.43
5.5.20.0030.06019.50
5.5.10.0100.07319.44
5.5.00.0070.05719.27
5.4.450.0030.04019.18
5.4.440.0070.03719.57
5.4.430.0030.03719.47
5.4.420.0000.04319.58
5.4.410.0000.04019.34
5.4.400.0070.04719.08
5.4.390.0030.07318.98
5.4.380.0030.05319.14
5.4.370.0000.05019.08
5.4.360.0070.03719.21
5.4.350.0070.05719.16
5.4.340.0070.04719.20
5.4.320.0130.05019.24
5.4.310.0100.06318.88
5.4.300.0070.04018.97
5.4.290.0070.06019.14
5.4.280.0000.06319.24
5.4.270.0070.08318.85
5.4.260.0230.03019.12
5.4.250.0030.04018.96
5.4.240.0100.06019.14
5.4.230.0170.07018.84
5.4.220.0070.03718.91
5.4.210.0070.07018.87
5.4.200.0070.04719.13
5.4.190.0100.06719.10
5.4.180.0070.08019.23
5.4.170.0130.03319.07
5.4.160.0000.06018.83
5.4.150.0030.04319.13
5.4.140.0070.05016.40
5.4.130.0070.07316.46
5.4.120.0000.04316.44
5.4.110.0100.03016.35
5.4.100.0070.04016.32
5.4.90.0030.04716.51
5.4.80.0030.04016.37
5.4.70.0100.07016.50
5.4.60.0100.07016.31
5.4.50.0030.07316.35
5.4.40.0130.06716.45
5.4.30.0030.07716.42
5.4.20.0100.06316.52
5.4.10.0030.07016.52
5.4.00.0030.03715.78
5.3.290.0070.07714.71
5.3.280.0030.08314.52
5.3.270.0130.06314.70
5.3.260.0070.08014.68
5.3.250.0030.07014.67
5.3.240.0070.06014.64
5.3.230.0030.04714.79
5.3.220.0000.04014.76
5.3.210.0100.03314.61
5.3.200.0030.08014.61
5.3.190.0100.07314.66
5.3.180.0070.04014.66
5.3.170.0070.04714.61
5.3.160.0100.03314.48
5.3.150.0170.03314.52
5.3.140.0100.05314.59
5.3.130.0030.07714.58
5.3.120.0070.08014.66
5.3.110.0000.05314.60
5.3.100.0030.03714.12
5.3.90.0100.05714.21
5.3.80.0030.07314.05
5.3.70.0070.05014.11
5.3.60.0030.04314.00
5.3.50.0100.05313.98
5.3.40.0070.05713.90
5.3.30.0070.06313.98
5.3.20.0030.04013.72
5.3.10.0030.04013.68
5.3.00.0030.05313.83
5.2.170.0070.06011.15
5.2.160.0100.06011.21
5.2.150.0030.06011.15
5.2.140.0000.04011.23
5.2.130.0000.03311.09
5.2.120.0070.04311.14
5.2.110.0070.05711.08
5.2.100.0070.05711.11
5.2.90.0070.04711.11
5.2.80.0070.04311.17
5.2.70.0030.06011.28
5.2.60.0000.06710.97
5.2.50.0070.04311.06
5.2.40.0000.03710.92
5.2.30.0000.03310.90
5.2.20.0030.02710.92
5.2.10.0100.02710.78
5.2.00.0070.06010.72
5.1.60.0070.0479.94
5.1.50.0100.04310.10
5.1.40.0030.05710.00
5.1.30.0030.02710.43
5.1.20.0000.03010.38
5.1.10.0100.04310.09
5.1.00.0030.05310.13
5.0.50.0030.0338.56
5.0.40.0000.0478.45
5.0.30.0000.0478.23
5.0.20.0000.0438.38
5.0.10.0100.0138.17
5.0.00.0030.0708.16
4.4.90.0000.0277.43
4.4.80.0030.0337.43
4.4.70.0030.0137.43
4.4.60.0000.0177.43
4.4.50.0070.0207.43
4.4.40.0030.0507.43
4.4.30.0000.0307.43
4.4.20.0000.0377.43
4.4.10.0070.0307.43
4.4.00.0100.0477.43
4.3.110.0000.0277.43
4.3.100.0000.0177.43
4.3.90.0000.0177.43
4.3.80.0000.0377.43
4.3.70.0000.0377.43
4.3.60.0000.0237.43
4.3.50.0070.0337.43
4.3.40.0000.0537.43
4.3.30.0000.0307.43
4.3.20.0000.0207.43
4.3.10.0000.0407.43
4.3.00.0030.0337.43

preferences:
37.68 ms | 401 KiB | 5 Q