3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace Zend\Stdlib { use DateTimeZone; class DateTime extends \DateTime { public function __construct($time = 'now', \DateTimeZone $timezone = null) { // workaround not required for PHP 5.3.7 or newer if(version_compare(PHP_VERSION, '5.3.7','>=')){ if($timezone) { return parent::__construct($time, $timezone); } else { return parent::__construct($time); } } // Check if using relative constructs if(!stristr($time, 'last') && !stristr($time, 'first')){ if($timezone) { return parent::__construct($time, $timezone); } else { return parent::__construct($time); } } // Use current time with constructor to prevent setting 'first_last_day_of' flag parent::__construct('now', $timezone); // Set the timestamp by relying on strtotime and avoiding setting the // internal 'first_last_day_of' flag of DateTime object. $this->setTimestamp( strtotime($time, $this->getTimestamp()) ); return $this; } public function modify($modify) { // Workaround not required for PHP 5.3.7 or newer if(version_compare(PHP_VERSION, '5.3.7','>=')){ return parent::modify($modify); } // Check if using relative constructs if(!stristr($modify, 'last') && !stristr($modify, 'first')){ return parent::modify($modify); } // Set the timestamp by relying on strtotime and avoiding setting the // internal 'first_last_day_of' flag of DateTime object. $parsedTimestamp = strtotime($modify, $this->getTimestamp()); if ($parsedTimestamp === false) { return false; // something went wrong parsing the date } $this->setTimestamp($parsedTimestamp); return $this; } } $interval = new \DateInterval('P1D'); $dt = new DateTime('first day of feb 2010'); var_dump($dt); $dt->add($interval); var_dump($dt); }

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.3.60.0120.00616.73
8.3.50.0100.00816.55
8.3.40.0170.00318.84
8.3.30.0140.00318.83
8.3.20.0090.00018.76
8.3.10.0030.00618.84
8.3.00.0080.00019.51
8.2.180.0110.00417.00
8.2.170.0110.00722.96
8.2.160.0150.00018.86
8.2.150.0040.00424.18
8.2.140.0060.00324.66
8.2.130.0040.00426.16
8.2.120.0090.00020.77
8.2.110.0000.01020.21
8.2.100.0040.00817.84
8.2.90.0000.00818.16
8.2.80.0000.00920.96
8.2.70.0050.00317.63
8.2.60.0060.00317.63
8.2.50.0030.00617.75
8.2.40.0060.00319.35
8.2.30.0030.00617.82
8.2.20.0030.00617.62
8.2.10.0080.00017.81
8.2.00.0090.00017.84
8.1.280.0040.01125.92
8.1.270.0080.00023.99
8.1.260.0040.00426.35
8.1.250.0050.00328.09
8.1.240.0090.00020.77
8.1.230.0110.00422.75
8.1.220.0060.00317.77
8.1.210.0040.00418.81
8.1.200.0030.00617.37
8.1.190.0040.00417.48
8.1.180.0060.00318.10
8.1.170.0040.00417.62
8.1.160.0000.00818.89
8.1.150.0000.00718.84
8.1.140.0000.00817.70
8.1.130.0050.00219.33
8.1.120.0040.00417.63
8.1.110.0080.00017.70
8.1.100.0070.00017.54
8.1.90.0000.00817.60
8.1.80.0030.00317.67
8.1.70.0030.00317.60
8.1.60.0050.00317.66
8.1.50.0050.00417.55
8.1.40.0030.00617.52
8.1.30.0040.00417.71
8.1.20.0040.00417.78
8.1.10.0000.00817.53
8.1.00.0040.00417.64
8.0.300.0090.00019.96
8.0.290.0000.00916.88
8.0.280.0030.00318.15
8.0.270.0050.00217.34
8.0.260.0070.00018.52
8.0.250.0050.00216.99
8.0.240.0040.00417.09
8.0.230.0000.00817.00
8.0.220.0040.00417.03
8.0.210.0000.00717.00
8.0.200.0040.00417.06
8.0.190.0030.00317.11
8.0.180.0080.00416.95
8.0.170.0060.00516.91
8.0.160.0050.00217.05
8.0.150.0030.00616.88
8.0.140.0090.00016.86
8.0.130.0030.00313.43
8.0.120.0040.00416.82
8.0.110.0080.00017.12
8.0.100.0030.00517.14
8.0.90.0000.00817.00
8.0.80.0090.00617.00
8.0.70.0050.00216.86
8.0.60.0030.00617.05
8.0.50.0040.00417.05
8.0.30.0200.00017.24
8.0.20.0090.01017.22
8.0.10.0040.00417.00
8.0.00.0110.01117.01
7.4.330.0050.00013.14
7.4.320.0030.00516.75
7.4.300.0000.00616.63
7.4.290.0000.00716.73
7.4.280.0080.00016.64
7.4.270.0030.00316.54
7.4.260.0030.00313.40
7.4.250.0040.00416.73
7.4.240.0030.00316.54
7.4.230.0050.00516.82
7.4.220.0060.01616.60
7.4.210.0070.01016.73
7.4.200.0060.00216.57
7.4.190.0060.00316.83
7.4.160.0160.00016.82
7.4.150.0180.01316.79
7.4.140.0080.01416.75
7.4.130.0100.01016.56
7.4.120.0030.01416.78
7.4.110.0060.01416.54
7.4.100.0090.00916.73
7.4.90.0180.00016.70
7.4.80.0200.00419.39
7.4.70.0030.01416.64
7.4.60.0070.01016.72
7.4.50.0060.00316.55
7.4.40.0070.01116.81
7.4.30.0160.00716.64
7.4.00.0070.00715.13
7.3.330.0000.00613.16
7.3.320.0000.00513.30
7.3.310.0030.00316.28
7.3.300.0000.00716.42
7.3.290.0040.01216.38
7.3.280.0110.00616.36
7.3.270.0140.00316.70
7.3.260.0000.01716.75
7.3.250.0060.01116.67
7.3.240.0110.00816.54
7.3.230.0240.00016.45
7.3.210.0110.00616.58
7.3.200.0120.00616.52
7.3.190.0160.00716.57
7.3.180.0100.00716.47
7.3.170.0100.00716.64
7.3.160.0140.00316.42
7.3.120.0040.00714.89
7.2.330.0090.00916.56
7.2.320.0100.00616.52
7.2.310.0080.00916.55
7.2.300.0040.01416.47
7.2.290.0110.01416.52
7.2.00.0070.01019.50
7.1.100.0230.00318.11
7.1.70.0030.00917.25
7.1.60.0080.00317.38
7.1.50.0130.00917.21
7.1.00.0000.04322.43
7.0.200.0000.01716.82
7.0.140.0100.06722.07
7.0.120.0130.06322.05
7.0.60.0030.08319.98
7.0.50.0070.03717.91
7.0.40.0070.06020.10
7.0.30.0270.08720.13
7.0.20.0170.04720.12
7.0.10.0030.09020.12
7.0.00.0130.07720.06
5.6.280.0000.08020.95
5.6.210.0170.03320.51
5.6.200.0070.08018.29
5.6.190.0100.08320.48
5.6.180.0230.04320.64
5.6.170.0130.05020.45
5.6.160.0230.07020.50
5.6.150.0030.05718.25
5.6.140.0070.07718.29
5.6.130.0070.08018.26
5.6.120.0130.04021.02
5.6.110.0100.08721.00
5.6.100.0130.07021.13
5.6.90.0100.07321.12
5.6.80.0030.08320.55
5.6.70.3730.03720.49
5.5.350.0270.06320.36
5.5.340.0100.07318.05
5.5.330.0100.05020.35
5.5.320.0370.06020.26
5.5.310.0200.04720.50
5.5.300.0130.07717.96
5.5.290.0070.04018.06
5.5.280.0170.07020.87
5.5.270.0100.08020.79
5.5.260.0000.08720.66
5.5.250.0070.07720.72
5.5.240.0330.07320.17
5.4.450.0130.05319.53
5.4.440.0230.06019.55
5.4.430.0270.04019.54
5.4.420.0230.03319.64
5.4.410.0330.03319.06
5.4.400.0170.06719.14
5.4.390.0230.05018.94
5.4.380.0370.04019.01
5.4.370.0200.07318.86
5.4.360.0230.06719.18
5.4.350.0270.07318.88
5.4.340.0230.05718.88
5.4.320.0370.05318.88
5.4.310.0170.06018.98
5.4.300.0270.07319.21
5.4.290.0270.04019.09
5.4.280.0170.05019.24
5.4.270.0230.07019.08
5.4.260.0200.07319.24
5.4.250.0270.08018.98
5.4.240.0300.06718.86
5.4.230.0230.04018.85
5.4.220.0200.04718.94
5.4.210.0270.06718.93
5.4.200.0330.05019.18
5.4.190.0230.05019.08
5.4.180.0270.05019.11
5.4.170.0270.06719.13
5.4.160.0230.05319.13
5.4.150.0130.04319.07
5.4.140.0200.03316.41
5.4.130.0270.04016.54
5.4.120.0230.06716.37
5.4.110.0230.06316.58
5.4.100.0230.07016.57
5.4.90.0270.05716.41
5.4.80.0270.06016.55
5.4.70.0230.04716.30
5.4.60.0200.06716.54
5.4.50.0130.04716.32
5.4.40.0230.06716.37
5.4.30.0230.06716.16
5.4.20.0330.04316.64
5.4.10.0300.07016.26
5.4.00.0330.05315.78
5.3.290.0330.04714.88
5.3.280.0230.05014.88
5.3.270.0230.06014.88
5.3.260.0200.07714.88
5.3.250.0100.04314.88
5.3.240.0200.04714.88
5.3.230.0170.07014.88
5.3.220.0270.06314.88
5.3.210.0200.06014.88
5.3.200.0300.07014.88
5.3.190.0230.04314.88
5.3.180.0170.05014.88
5.3.170.0330.06014.88
5.3.160.0230.06014.88
5.3.150.0200.05314.88
5.3.140.0230.04014.88
5.3.130.0230.05314.88
5.3.120.0300.03014.88
5.3.110.0300.06314.88
5.3.100.0270.06714.88
5.3.90.0230.04014.88
5.3.80.0130.04314.88
5.3.70.0300.06714.88
5.3.60.0200.06014.88
5.3.50.0170.04014.88
5.3.40.0330.05714.88
5.3.30.0230.04014.88
5.3.20.0130.06014.88
5.3.10.0330.04714.88
5.3.00.0170.07314.88
5.2.170.0130.03314.88
5.2.160.0200.04014.88
5.2.150.0230.05314.88
5.2.140.0270.03714.88
5.2.130.0270.05314.88
5.2.120.0170.04714.88
5.2.110.0200.03714.88
5.2.100.0200.05314.88
5.2.90.0270.04014.88
5.2.80.0270.04014.88
5.2.70.0270.04714.88
5.2.60.0200.05314.88
5.2.50.0230.05714.88
5.2.40.0230.05714.88
5.2.30.0270.05714.88
5.2.20.0200.04714.88
5.2.10.0230.04714.88
5.2.00.0200.05714.88
5.1.60.0130.04014.88
5.1.50.0130.02714.88
5.1.40.0170.05314.88
5.1.30.0170.05314.88
5.1.20.0270.04314.88
5.1.10.0170.04714.88
5.1.00.0170.04714.88
5.0.50.0100.04014.88
5.0.40.0130.03314.88
5.0.30.0100.04714.88
5.0.20.0130.03714.88
5.0.10.0100.04014.88
5.0.00.0130.04714.88
4.4.90.0100.03314.88
4.4.80.0130.03014.88
4.4.70.0200.02014.88
4.4.60.0070.03314.88
4.4.50.0100.02714.88
4.4.40.0070.03314.88
4.4.30.0100.01714.88
4.4.20.0070.03014.88
4.4.10.0070.03714.88
4.4.00.0070.04014.88
4.3.110.0100.02314.88
4.3.100.0070.02014.88
4.3.90.0070.03014.88
4.3.80.0100.05314.88
4.3.70.0130.02714.88
4.3.60.0100.02314.88
4.3.50.0070.01314.88
4.3.40.0070.02314.88
4.3.30.0030.02314.88
4.3.20.0100.03014.88
4.3.10.0070.02314.88
4.3.00.0030.02714.88

preferences:
52.1 ms | 401 KiB | 5 Q