3v4l.org

run code in 300+ PHP versions simultaneously
<?php function add_weeks($weeks = 1, $base = 'now') { // normalise base to a unix timestamp if (!is_string($base)) { $base = intval($base); } else { $base = strtotime($base); } // get the date one week from the base $result = strtotime(sprintf("@{$base} +{$weeks} weeks", $base, $weeks)); // if it falls in a different month, get the last day of the base month if (date('n', $base) !== date('n', $result)) { $result = strtotime("@{$base} last day of month"); } return $result; } echo date('Y-m-d', add_weeks(1)) . "\n"; echo date('Y-m-d', add_weeks(2)) . "\n"; echo date('Y-m-d', add_weeks(1, '2012-06-18')) . "\n"; echo date('Y-m-d', add_weeks(2, '2012-06-18')) . "\n";

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.0040.01818.31
8.3.50.0090.01021.96
8.3.40.0040.01118.82
8.3.30.0170.00318.79
8.3.20.0060.00320.21
8.3.10.0000.00822.09
8.3.00.0030.00622.32
8.2.180.0090.00618.41
8.2.170.0160.00322.96
8.2.160.0100.00320.89
8.2.150.0080.00024.18
8.2.140.0080.00024.66
8.2.130.0040.00426.16
8.2.120.0000.00819.48
8.2.110.0000.01022.23
8.2.100.0040.00717.97
8.2.90.0040.00419.42
8.2.80.0050.00318.05
8.2.70.0060.00317.88
8.2.60.0030.00517.93
8.2.50.0050.00318.07
8.2.40.0000.00818.41
8.2.30.0080.00018.10
8.2.20.0050.00318.01
8.2.10.0000.00817.90
8.2.00.0030.00518.00
8.1.280.0170.00025.92
8.1.270.0040.00423.99
8.1.260.0030.00526.35
8.1.250.0030.00628.09
8.1.240.0040.00423.84
8.1.230.0110.00019.11
8.1.220.0000.00917.79
8.1.210.0000.00818.77
8.1.200.0060.00317.60
8.1.190.0000.01217.65
8.1.180.0040.00418.83
8.1.170.0050.00318.82
8.1.160.0040.00423.78
8.1.150.0000.00718.79
8.1.140.0070.00017.79
8.1.130.0030.00317.90
8.1.120.0040.00417.74
8.1.110.0040.00417.74
8.1.100.0050.00317.70
8.1.90.0040.00417.62
8.1.80.0040.00417.78
8.1.70.0070.00017.71
8.1.60.0060.00317.83
8.1.50.0000.00817.59
8.1.40.0060.00317.63
8.1.30.0030.00517.75
8.1.20.0060.00317.78
8.1.10.0050.00317.64
8.1.00.0040.00417.68
8.0.300.0060.00318.77
8.0.290.0000.00717.30
8.0.280.0070.00018.60
8.0.270.0000.00817.34
8.0.260.0070.00317.07
8.0.250.0030.00317.14
8.0.240.0040.00417.22
8.0.230.0000.00917.24
8.0.220.0030.00317.20
8.0.210.0040.00417.16
8.0.200.0040.00417.20
8.0.190.0070.00717.24
8.0.180.0040.00417.20
8.0.170.0040.00417.14
8.0.160.0040.00417.26
8.0.150.0030.00317.00
8.0.140.0040.00417.19
8.0.130.0000.00613.50
8.0.120.0040.00417.23
8.0.110.0040.00417.07
8.0.100.0030.00516.97
8.0.90.0070.00017.00
8.0.80.0030.01417.16
8.0.70.0040.00417.22
8.0.60.0040.00417.13
8.0.50.0000.00816.96
8.0.30.0120.01117.23
8.0.20.0110.00917.49
8.0.10.0070.00017.35
8.0.00.0150.00617.01
7.4.330.0000.00515.09
7.4.320.0030.00316.78
7.4.300.0040.00416.62
7.4.290.0000.00716.65
7.4.280.0000.00716.74
7.4.270.0050.00316.88
7.4.260.0030.00416.78
7.4.250.0000.00816.66
7.4.240.0040.00416.78
7.4.230.0030.00316.81
7.4.220.0120.00916.85
7.4.210.0070.00916.87
7.4.200.0080.00016.71
7.4.190.0050.00216.54
7.4.160.0060.01616.85
7.4.150.0030.01817.40
7.4.140.0100.00717.86
7.4.130.0130.00616.89
7.4.120.0080.01016.85
7.4.110.0090.00916.80
7.4.100.0120.00616.78
7.4.90.0090.01516.82
7.4.80.0090.01319.39
7.4.70.0090.00916.67
7.4.60.0060.01316.81
7.4.50.0000.00516.69
7.4.40.0090.00922.77
7.4.30.0080.00816.70
7.4.00.0000.01714.93
7.3.330.0030.00313.48
7.3.320.0000.00613.45
7.3.310.0000.00716.60
7.3.300.0000.00616.57
7.3.290.0070.00716.52
7.3.280.0100.00616.55
7.3.270.0130.00417.40
7.3.260.0070.01116.64
7.3.250.0120.00716.71
7.3.240.0100.01016.69
7.3.230.0090.00916.85
7.3.210.0100.00716.60
7.3.200.0160.00919.39
7.3.190.0120.00916.75
7.3.180.0030.01216.78
7.3.170.0090.01116.69
7.3.160.0100.00716.49
7.3.120.0100.00715.16
7.2.330.0120.00616.97
7.2.320.0120.00916.96
7.2.310.0110.00516.67
7.2.300.0120.00616.86
7.2.290.0130.00916.96
7.2.60.0100.00617.15
7.2.00.0060.00619.79
7.1.200.0060.00616.19
7.1.100.0000.01018.64
7.1.70.0040.00417.54
7.1.60.0100.01319.82
7.1.50.0000.01117.27
7.1.00.0030.07722.58
7.0.200.0050.00317.04
7.0.140.0000.07721.95
7.0.80.0500.04319.94
7.0.70.0100.07020.01
7.0.60.0300.07019.76
7.0.50.0100.07720.34
7.0.40.0030.05320.10
7.0.30.0100.07720.11
7.0.20.0000.06020.13
7.0.10.0000.09320.03
7.0.00.0100.07019.95
5.6.280.0000.07721.02
5.6.230.0200.07020.60
5.6.220.0130.08020.74
5.6.210.0230.06320.60
5.6.200.0130.07721.06
5.6.190.0230.05321.04
5.6.180.0070.04721.01
5.6.170.0070.05021.06
5.6.160.0170.07721.02
5.6.150.0070.06721.01
5.6.140.0030.07021.01
5.6.130.0030.06021.01
5.6.120.0170.07021.00
5.6.110.0000.06021.00
5.6.100.0070.08321.10
5.6.90.0030.05321.16
5.6.80.0030.06320.45
5.6.70.0100.08020.34
5.6.60.0070.05720.34
5.6.50.0130.06020.44
5.6.40.0170.07720.41
5.6.30.0200.06720.32
5.6.20.0000.05720.42
5.6.10.0100.07020.47
5.6.00.0030.06020.51
5.5.370.0100.08320.35
5.5.360.0200.06720.45
5.5.350.0130.05320.42
5.5.340.0130.08020.93
5.5.330.0000.07020.80
5.5.320.0100.07720.77
5.5.310.0070.04720.87
5.5.300.0030.08720.85
5.5.290.0070.04020.64
5.5.280.0070.04720.79
5.5.270.0070.07020.90
5.5.260.0100.04020.92
5.5.250.0070.07720.71
5.5.240.0070.08020.30
5.5.230.0070.08320.21
5.5.220.0070.08020.29
5.5.210.0030.05320.27
5.5.200.0130.07320.08
5.5.190.0030.08020.19
5.5.180.0070.08320.15
5.5.160.0070.07720.22
5.5.150.0130.07720.22
5.5.140.0070.08020.20
5.5.130.0070.05720.23
5.5.120.0070.08020.18
5.5.110.0100.07320.20
5.5.100.0070.04020.07
5.5.90.0000.08320.13
5.5.80.0070.08019.94
5.5.70.0070.04020.11
5.5.60.0170.06020.05
5.5.50.0000.06320.14
5.5.40.0130.07320.06
5.5.30.0170.07020.09
5.5.20.0030.08020.08
5.5.10.0030.07720.11
5.5.00.0100.08020.07
5.4.450.0170.04319.56
5.4.440.0170.04319.36
5.4.430.0170.07719.18
5.4.420.0170.04319.27
5.4.410.0070.07319.04
5.4.400.0070.07719.05
5.4.390.0030.07319.02
5.4.380.0100.06319.16
5.4.370.0000.08319.14
5.4.360.0070.05719.13
5.4.350.0030.06719.20
5.4.340.0200.06719.16
5.4.320.0200.06719.14
5.4.310.0000.06019.15
5.4.300.0130.06319.12
5.4.290.0000.04719.03
5.4.280.0070.08019.18
5.4.270.0000.07019.02
5.4.260.0100.06718.94
5.4.250.0070.04019.22
5.4.240.0170.06019.18
5.4.230.0200.08319.02
5.4.220.0000.05019.04
5.4.210.0070.07319.13
5.4.200.0070.05019.20
5.4.190.0100.07019.22
5.4.180.0100.07019.13
5.4.170.0030.05719.17
5.4.160.0200.06318.82
5.4.150.0070.05719.02
5.4.140.0130.06716.45
5.4.130.0070.07316.25
5.4.120.0170.06316.45
5.4.110.0030.08016.48
5.4.100.0100.07316.35
5.4.90.0030.07016.34
5.4.80.0170.04716.27
5.4.70.0100.06316.45
5.4.60.0070.07316.25
5.4.50.0100.06716.36
5.4.40.0100.07016.34
5.4.30.0070.07016.30
5.4.20.0100.07016.24
5.4.10.0030.07016.31
5.4.00.0100.07315.86
5.3.290.0170.06314.77
5.3.280.0000.04714.54
5.3.270.0130.07014.63
5.3.260.0100.07714.74
5.3.250.0070.05314.59
5.3.240.0070.06314.72
5.3.230.0130.06714.62
5.3.220.0100.07314.66
5.3.210.0070.08314.50
5.3.200.0130.07314.60
5.3.190.0030.07714.49
5.3.180.0130.07314.64
5.3.170.0070.07014.67
5.3.160.0100.07314.57
5.3.150.0070.08014.53
5.3.140.0030.07014.61
5.3.130.0130.06314.69
5.3.120.0130.06014.58
5.3.110.0100.07314.52
5.3.100.0100.07314.02
5.3.90.0100.08313.98
5.3.80.0030.08014.02
5.3.70.0000.08014.13
5.3.60.0170.06314.02
5.3.50.0000.07713.84
5.3.40.0030.07713.96
5.3.30.0100.05713.83
5.3.20.0100.03713.80
5.3.10.0000.06013.70
5.3.00.0070.05313.63
5.2.170.0030.06011.09
5.2.160.0100.05711.15
5.2.150.0070.06011.21
5.2.140.0070.06011.00
5.2.130.0030.04011.17
5.2.120.0030.06311.09
5.2.110.0030.06311.12
5.2.100.0100.05711.19
5.2.90.0030.03711.09
5.2.80.0070.04011.15
5.2.70.0070.05311.12
5.2.60.0070.06011.08
5.2.50.0030.06011.07
5.2.40.0070.04711.11
5.2.30.0070.05010.91
5.2.20.0000.05310.89
5.2.10.0000.06310.87
5.2.00.0070.05710.65
5.1.60.0070.0539.98
5.1.50.0000.0579.83
5.1.40.0070.04010.07
5.1.30.0000.06010.29
5.1.20.0030.05710.28
5.1.10.0100.04310.13
5.1.00.0130.0479.96
5.0.50.0070.0408.55
5.0.40.0030.0478.41
5.0.30.0030.0578.08
5.0.20.0030.0438.09
5.0.10.0100.0378.17
5.0.00.0000.0578.22
4.4.90.0070.0337.57
4.4.80.0030.0307.57
4.4.70.0070.0337.57
4.4.60.0000.0377.57
4.4.50.0000.0407.57
4.4.40.0070.0507.57
4.4.30.0030.0337.57
4.4.20.0030.0337.57
4.4.10.0000.0377.57
4.4.00.0030.0477.57
4.3.110.0000.0377.57
4.3.100.0000.0207.57
4.3.90.0030.0337.57
4.3.80.0030.0437.57
4.3.70.0000.0307.57
4.3.60.0030.0337.57
4.3.50.0000.0377.57
4.3.40.0070.0477.57
4.3.30.0030.0237.57
4.3.20.0000.0307.57
4.3.10.0000.0277.57
4.3.00.0000.0237.57

preferences:
53.56 ms | 401 KiB | 5 Q