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); var_dump($myDateTime1->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)
8.0.110.0050.00317.00
8.0.100.0040.00416.88
8.0.90.0050.00316.93
8.0.80.0100.00617.00
8.0.70.0080.00017.01
8.0.60.0040.00417.14
8.0.50.0050.00317.09
8.0.30.0130.00817.15
8.0.20.0090.01117.40
8.0.10.0000.00717.21
8.0.00.0070.01416.86
7.4.240.0050.00216.69
7.4.230.0080.00016.69
7.4.220.0160.01016.70
7.4.210.0090.01216.88
7.4.200.0030.00316.79
7.4.190.0050.00316.96
7.4.160.0170.00616.71
7.4.150.0090.00917.40
7.4.140.0120.00717.86
7.4.130.0100.00816.64
7.4.120.0120.00816.67
7.4.110.0130.00616.84
7.4.100.0090.01316.76
7.4.90.0160.00316.78
7.4.80.0070.01016.47
7.4.70.0000.01816.79
7.4.60.0150.00616.71
7.4.50.0060.00316.59
7.4.40.0070.00522.77
7.4.30.0100.01016.80
7.4.00.0120.00615.33
7.3.300.0040.00416.46
7.3.290.0030.00316.48
7.3.280.0090.01016.43
7.3.270.0130.00617.40
7.3.260.0110.01116.57
7.3.250.0120.00816.60
7.3.240.0030.01416.39
7.3.230.0070.01016.50
7.3.210.0090.00916.89
7.3.200.0140.00719.39
7.3.190.0040.01716.53
7.3.180.0090.00916.70
7.3.170.0070.01016.56
7.3.160.0040.01316.68
7.3.120.0100.00615.00
7.3.110.0130.00715.27
7.3.100.0040.01515.23
7.3.90.0060.00914.98
7.3.80.0030.01315.20
7.3.70.0070.00715.11
7.3.60.0080.00814.85
7.3.50.0030.01015.14
7.3.40.0000.00914.93
7.3.30.0030.01014.78
7.3.20.0030.01016.74
7.3.10.0070.00716.84
7.3.00.0080.00516.82
7.2.330.0060.01316.77
7.2.320.0140.00316.80
7.2.310.0080.01416.77
7.2.300.0100.00716.81
7.2.290.0100.01016.92
7.2.250.0000.01715.32
7.2.240.0100.01015.18
7.2.230.0160.00014.77
7.2.220.0110.00615.52
7.2.210.0000.01215.18
7.2.200.0060.00914.96
7.2.190.0030.00915.27
7.2.180.0070.00715.22
7.2.170.0040.00715.19
7.2.160.0060.00615.25
7.2.150.0100.00617.12
7.2.140.0030.01217.11
7.2.130.0070.00717.00
7.2.120.0030.00916.95
7.2.110.0040.01116.99
7.2.100.0080.00717.02
7.2.90.0050.00817.06
7.2.80.0030.01216.88
7.2.70.0080.00616.94
7.2.60.0030.01016.97
7.2.50.0030.01217.06
7.2.40.0090.00516.90
7.2.30.0090.00517.03
7.2.20.0100.00517.04
7.2.10.0070.00516.88
7.2.00.0030.01017.57
7.1.330.0070.00715.96
7.1.320.0070.00615.80
7.1.310.0120.00615.84
7.1.300.0060.00615.98
7.1.290.0030.01015.94
7.1.280.0060.00616.13
7.1.270.0110.00015.96
7.1.260.0060.01315.95
7.1.250.0010.01215.89
7.1.240.0110.00316.13
7.1.230.0030.01316.00
7.1.220.0060.00715.92
7.1.210.0080.00416.17
7.1.200.0070.00515.89
7.1.190.0000.00915.85
7.1.180.0070.00315.95
7.1.170.0060.00916.00
7.1.160.0100.00616.07
7.1.150.0030.01316.00
7.1.140.0060.00615.92
7.1.130.0100.00316.14
7.1.120.0070.00715.94
7.1.110.0040.00815.95
7.1.100.0040.00717.11
7.1.90.0090.00316.00
7.1.80.0070.00415.79
7.1.70.0080.00916.40
7.1.60.0100.00717.73
7.1.50.0110.00516.53
7.1.40.0000.01015.71
7.1.30.0160.00015.97
7.1.20.0060.01115.79
7.1.10.0110.00416.09
7.1.00.0030.04419.18
7.0.330.0000.01515.32
7.0.320.0040.00415.35
7.0.310.0060.00915.51
7.0.300.0090.00615.67
7.0.290.0000.00915.66
7.0.280.0080.00815.77
7.0.270.0070.00715.64
7.0.260.0060.00915.63
7.0.250.0070.00715.63
7.0.240.0030.01015.38
7.0.230.0090.00615.46
7.0.220.0120.00315.41
7.0.210.0100.00315.38
7.0.200.0000.00816.29
7.0.190.0030.00915.48
7.0.180.0030.01315.60
7.0.170.0080.00315.85
7.0.160.0000.01115.60
7.0.150.0060.00915.74
7.0.140.0070.03818.75
7.0.130.0090.00615.73
7.0.120.0040.01215.68
7.0.110.0070.01015.77
7.0.100.0090.00915.38
7.0.90.0070.01015.52
7.0.80.0040.00415.28
7.0.70.0130.00015.51
7.0.60.0080.02617.79
7.0.50.0080.04516.91
7.0.40.0100.04416.84
7.0.30.0200.03816.90
7.0.20.0160.02116.96
7.0.10.0160.04316.95
7.0.00.0060.03216.98
5.6.400.0000.02014.72
5.6.390.0030.00614.51
5.6.380.0030.01314.65
5.6.370.0030.01014.65
5.6.360.0030.00714.20
5.6.350.0100.00714.45
5.6.340.0030.01014.37
5.6.330.0000.01814.65
5.6.320.0050.00514.78
5.6.310.0060.01014.61
5.6.300.0030.01014.70
5.6.290.0080.00414.65
5.6.280.0030.04117.90
5.6.270.0060.00914.60
5.6.260.0070.01014.83
5.6.250.0100.00314.46
5.6.240.0030.00714.45
5.6.230.0030.01014.50
5.6.220.0040.01114.62
5.6.210.0150.02817.67
5.6.200.0040.02616.30
5.6.190.0120.04317.36
5.6.180.0220.03817.54
5.6.170.0090.02817.51
5.6.160.0080.02317.56
5.6.150.0040.03516.39
5.6.140.0030.03716.37
5.6.130.0030.04016.39
5.6.120.0070.04717.85
5.6.110.0020.04917.78
5.6.100.0040.02817.79
5.6.90.0060.02317.74
5.6.80.0130.03217.56
5.6.70.0200.04017.62
5.6.60.0110.00714.46
5.6.50.0030.01014.59
5.6.40.0000.01214.62
5.6.30.0080.00814.41
5.6.20.0060.00314.30
5.6.10.0030.00614.45
5.6.00.0040.00714.64
5.5.380.0060.00814.14
5.5.370.0100.00014.41
5.5.360.0090.00614.59
5.5.350.0100.02717.50
5.5.340.0030.04716.18
5.5.330.0130.03317.44
5.5.320.0050.02317.41
5.5.310.0190.04117.40
5.5.300.0120.04216.15
5.5.290.0030.03616.07
5.5.280.0110.04317.74
5.5.270.0080.04317.75
5.5.260.0080.04317.75
5.5.250.0170.03617.66
5.5.240.0170.03017.37
5.5.230.0090.00014.33
5.5.220.0030.00614.36
5.5.210.0000.01714.08
5.5.200.0030.00914.05
5.5.190.0000.01414.41
5.5.180.0040.01114.29
5.5.170.0070.00414.45
5.5.160.0030.01114.23
5.5.150.0000.00914.26
5.5.140.0000.01214.04
5.5.130.0060.00914.25
5.5.120.0030.00614.38
5.5.110.0000.00914.48
5.5.100.0070.00714.27
5.5.90.0070.00414.48
5.5.80.0030.00714.69
5.5.70.0030.00714.45
5.5.60.0110.00314.20
5.5.50.0030.01014.45
5.5.40.0070.00414.41
5.5.30.0030.00614.45
5.5.20.0090.00614.56
5.5.10.0050.00514.49
5.5.00.0060.00614.54
5.4.450.0350.03215.38
5.4.440.0380.03315.35
5.4.430.0330.02815.38
5.4.420.0320.03315.09
5.4.410.0050.04315.15
5.4.400.0460.03014.86
5.4.390.0470.03814.75
5.4.380.0060.03614.91
5.4.370.0090.02614.90
5.4.360.0050.02314.83
5.4.350.0050.02111.63
5.4.340.0060.02211.57
5.4.330.0100.00310.98
5.4.320.0070.02011.79
5.4.310.0020.02511.83
5.4.300.0050.02211.83
5.4.290.0050.02311.88
5.4.280.0050.02611.72
5.4.270.0070.02511.80
5.4.260.0050.02211.70
5.4.250.0050.02711.76
5.4.240.0050.02211.71
5.4.230.0040.02111.70
5.4.220.0110.02611.79
5.4.210.0120.02211.69
5.4.200.0180.03311.69
5.4.190.0070.02611.69
5.4.180.0110.02411.76
5.4.170.0070.02811.69
5.4.160.0090.02611.69
5.4.150.0090.02711.69
5.4.140.0120.02611.62
5.4.130.0100.02511.73
5.4.120.0100.02311.62
5.4.110.0190.04511.50
5.4.100.0070.02811.63
5.4.90.0090.02711.50
5.4.80.0110.02611.60
5.4.70.0080.02511.59
5.4.60.0230.05011.59
5.4.50.0100.02311.50
5.4.40.0100.02511.49
5.4.30.0070.03011.58
5.4.20.0150.02111.52
5.4.10.0100.02711.49
5.4.00.0070.02611.36
5.3.290.0030.02511.89
5.3.280.0040.02111.85
5.3.270.0080.02911.85
5.3.260.0120.02111.85
5.3.250.0140.04911.85
5.3.240.0130.02211.85
5.3.230.0110.02711.84
5.3.220.0210.05911.83
5.3.210.0100.02411.83
5.3.200.0090.02611.83
5.3.190.0100.02611.83
5.3.180.0250.04111.82
5.3.170.0090.02711.82
5.3.160.0110.02711.83
5.3.150.0130.02211.82
5.3.140.0100.02611.82
5.3.130.0120.02611.81
5.3.120.0090.02711.82
5.3.110.0130.02311.81
5.3.100.0130.02411.56
5.3.90.0070.02811.55
5.3.80.0100.02511.55
5.3.70.0090.02711.54
5.3.60.0110.02511.54
5.3.50.0130.03611.51
5.3.40.0090.02811.51
5.3.30.0140.03811.53
5.3.20.0090.02511.38
5.3.10.0110.02011.37
5.3.00.0130.02111.36
5.2.170.0210.0579.23
5.2.160.0130.0339.22
5.2.150.0130.0349.23
5.2.140.0110.0369.22
5.2.130.0210.0579.18
5.2.120.0160.0329.18
5.2.110.0160.0349.20
5.2.100.0190.0269.20
5.2.90.0170.0329.20
5.2.80.0120.0399.18
5.2.70.0120.0379.18
5.2.60.0150.0629.14
5.2.50.0080.0399.11
5.2.40.0150.0329.09
5.2.30.0150.0319.05
5.2.20.0120.0379.06
5.2.10.0170.0328.96
5.2.00.0190.0588.81
5.1.60.0130.0308.10
5.1.50.0120.0298.10
5.1.40.0080.0318.08
5.1.30.0120.0328.43
5.1.20.0120.0308.45
5.1.10.0110.0338.18
5.1.00.0120.0308.18
5.0.50.0130.0246.66
5.0.40.0140.0216.52
5.0.30.0130.0376.33
5.0.20.0130.0256.30
5.0.10.0110.0216.27
5.0.00.0110.0356.27
4.4.90.0080.0174.78
4.4.80.0050.0214.76
4.4.70.0060.0214.75
4.4.60.0060.0204.75
4.4.50.0090.0164.77
4.4.40.0080.0284.71
4.4.30.0050.0214.76
4.4.20.0060.0194.84
4.4.10.0110.0154.85
4.4.00.0060.0294.76
4.3.110.0040.0204.66
4.3.100.0110.0134.66
4.3.90.0160.0384.63
4.3.80.0080.0284.58
4.3.70.0090.0174.63
4.3.60.0070.0174.63
4.3.50.0080.0174.63
4.3.40.0100.0244.54
4.3.30.0060.0193.30
4.3.20.0050.0183.28
4.3.10.0050.0183.24
4.3.00.0070.0176.66

preferences:
32.52 ms | 401 KiB | 5 Q