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); } var_dump(date('Y-m-d', $base)); // get the date one week from the base $result = strtotime(sprintf("@{$base} +{$weeks} weeks", $base, $weeks)); var_dump(date('Y-m-d', $result)); // if it falls in a different month, get the last day of the base month if (date('n', $base) !== date('n', $result)) { $result = strtotime("last day of this month @{$base}"); } 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.0200.00018.55
8.3.50.0130.00822.11
8.3.40.0140.00018.83
8.3.30.0150.00019.23
8.3.20.0040.00420.34
8.3.10.0000.00821.94
8.3.00.0080.00022.32
8.2.180.0030.01416.88
8.2.170.0070.01022.96
8.2.160.0120.00920.92
8.2.150.0040.00424.18
8.2.140.0060.00324.66
8.2.130.0000.00826.16
8.2.120.0040.00719.75
8.2.110.0060.00322.32
8.2.100.0080.00319.57
8.2.90.0000.00819.38
8.2.80.0040.00417.97
8.2.70.0030.00617.63
8.2.60.0000.00818.05
8.2.50.0000.00818.07
8.2.40.0080.00018.09
8.2.30.0070.00018.21
8.2.20.0040.00418.03
8.2.10.0050.00217.84
8.2.00.0000.00818.02
8.1.280.0090.01225.92
8.1.270.0050.00223.99
8.1.260.0080.00026.35
8.1.250.0000.00828.09
8.1.240.0000.00924.02
8.1.230.0000.01119.25
8.1.220.0000.00817.80
8.1.210.0040.00418.77
8.1.200.0060.00317.60
8.1.190.0030.00617.63
8.1.180.0040.00418.64
8.1.170.0000.00818.89
8.1.160.0000.00822.01
8.1.150.0000.00818.84
8.1.140.0030.00517.70
8.1.130.0000.00717.84
8.1.120.0000.00717.77
8.1.110.0000.00717.60
8.1.100.0000.00817.77
8.1.90.0000.00717.75
8.1.80.0080.00017.75
8.1.70.0080.00017.75
8.1.60.0000.00817.75
8.1.50.0040.00417.73
8.1.40.0040.00417.69
8.1.30.0040.00417.80
8.1.20.0040.00417.84
8.1.10.0030.00617.62
8.1.00.0030.00617.74
8.0.300.0000.00718.77
8.0.290.0070.00017.18
8.0.280.0030.00318.54
8.0.270.0060.00317.42
8.0.260.0090.00016.98
8.0.250.0000.00817.12
8.0.240.0050.00217.23
8.0.230.0060.00317.15
8.0.220.0070.00017.14
8.0.210.0070.00017.14
8.0.200.0000.00817.23
8.0.190.0000.01217.13
8.0.180.0060.00317.25
8.0.170.0090.00017.21
8.0.160.0030.00517.11
8.0.150.0040.00417.13
8.0.140.0000.00717.18
8.0.130.0000.00513.56
8.0.120.0040.00417.13
8.0.110.0050.00217.11
8.0.100.0040.00417.18
8.0.90.0030.00317.08
8.0.80.0080.01117.13
8.0.70.0000.00817.10
8.0.60.0070.00017.21
8.0.50.0040.00417.13
8.0.30.0140.00717.36
8.0.20.0120.00717.40
8.0.10.0040.00417.11
8.0.00.0060.01317.07
7.4.330.0050.00015.00
7.4.320.0000.00616.74
7.4.300.0030.00316.83
7.4.290.0000.00916.82
7.4.280.0030.00316.71
7.4.270.0050.00216.63
7.4.260.0040.00416.70
7.4.250.0080.00016.78
7.4.240.0030.00516.74
7.4.230.0030.00316.92
7.4.220.0120.00916.76
7.4.210.0110.00916.72
7.4.200.0000.00716.83
7.4.190.0000.00716.77
7.4.160.0120.00416.58
7.4.150.0200.00417.40
7.4.140.0090.01117.86
7.4.130.0110.00716.73
7.4.120.0100.00716.69
7.4.110.0100.00716.86
7.4.100.0090.01416.69
7.4.90.0100.01016.83
7.4.80.0100.00719.39
7.4.70.0130.00316.77
7.4.60.0050.01116.95
7.4.50.0000.00916.79
7.4.40.0080.01122.77
7.4.30.0030.01317.02
7.4.00.0040.01115.16
7.3.330.0030.00313.34
7.3.320.0020.00213.50
7.3.310.0030.00516.55
7.3.300.0040.00416.53
7.3.290.0060.00916.59
7.3.280.0110.00716.52
7.3.270.0060.01117.40
7.3.260.0060.01216.66
7.3.250.0160.00316.62
7.3.240.0110.00716.56
7.3.230.0060.01116.61
7.3.210.0090.00916.86
7.3.200.0060.01019.39
7.3.190.0080.01116.87
7.3.180.0100.01016.83
7.3.170.0060.01316.49
7.3.160.0140.00316.71
7.3.120.0110.00315.19
7.3.10.0060.01116.68
7.3.00.0100.00516.76
7.2.330.0060.01216.75
7.2.320.0080.01116.89
7.2.310.0130.00916.61
7.2.300.0070.01017.00
7.2.290.0170.00016.90
7.2.130.0080.00716.84
7.2.120.0080.00916.96
7.2.110.0130.00516.79
7.2.100.0070.00716.79
7.2.90.0120.00416.77
7.2.80.0040.01117.12
7.2.70.0140.00816.95
7.2.60.0080.00717.05
7.2.50.0120.01016.82
7.2.40.0110.00816.89
7.2.30.0120.01017.08
7.2.20.0100.00917.03
7.2.10.0110.00817.02
7.2.00.0080.00817.81
7.1.250.0080.00715.81
7.1.100.0030.01018.06
7.1.70.0060.00917.15
7.1.60.0160.00719.82
7.1.50.0070.01117.32
7.1.00.0070.07322.46
7.0.200.0040.00417.08
7.0.140.0200.06021.98
7.0.80.0500.08319.96
7.0.70.0030.04319.88
7.0.60.0470.08319.89
7.0.50.0500.08720.39
7.0.40.0130.07020.09
7.0.30.0070.07320.05
7.0.20.0100.04720.14
7.0.10.0070.09020.14
7.0.00.0000.04320.04
5.6.280.0000.07320.82
5.6.230.0100.04720.63
5.6.220.0100.04720.52
5.6.210.0070.07020.67
5.6.200.0030.06320.95
5.6.190.0100.04720.94
5.6.180.0070.04720.94
5.6.170.0100.07321.08
5.6.160.0130.05020.94
5.6.150.0070.03720.94
5.6.140.0030.08721.02
5.6.130.0100.04020.96
5.6.120.0200.07021.02
5.6.110.0070.07021.05
5.6.100.0030.06721.03
5.6.90.0070.05720.93
5.6.80.0070.03320.41
5.6.70.0130.07720.35
5.6.60.0070.03320.33
5.6.50.0030.08320.49
5.6.40.0100.03020.49
5.6.30.0030.05320.41
5.6.20.0100.06020.39
5.6.10.0170.04320.37
5.6.00.0070.07720.26
5.5.370.0030.08720.46
5.5.360.0070.06020.42
5.5.350.0100.08320.38
5.5.340.0130.07320.64
5.5.330.0130.06320.88
5.5.320.0070.07320.86
5.5.310.0100.08020.87
5.5.300.0100.07020.77
5.5.290.0130.07020.73
5.5.280.0130.09720.83
5.5.270.0070.05020.91
5.5.260.0130.04720.79
5.5.250.0070.08020.73
5.5.240.0030.08020.30
5.5.230.0070.04720.21
5.5.220.0070.08020.22
5.5.210.0100.07320.30
5.5.200.0070.03320.26
5.5.190.0030.08020.24
5.5.180.0130.05020.25
5.5.160.0030.04020.13
5.5.150.0100.05720.17
5.5.140.0030.04320.27
5.5.130.0000.04720.11
5.5.120.0070.03720.27
5.5.110.0070.06320.20
5.5.100.0030.06020.02
5.5.90.0100.03320.07
5.5.80.0000.06019.97
5.5.70.0070.04020.07
5.5.60.0070.06720.16
5.5.50.0070.03720.05
5.5.40.0100.03320.05
5.5.30.0000.04020.13
5.5.20.0100.07320.05
5.5.10.0030.05020.03
5.5.00.0070.04720.04
5.4.450.0070.06319.46
5.4.440.0070.07719.37
5.4.430.0070.07319.38
5.4.420.0030.05019.44
5.4.410.0000.04319.36
5.4.400.0070.03319.10
5.4.390.0030.08019.13
5.4.380.0070.03718.88
5.4.370.0070.07319.05
5.4.360.0030.04018.91
5.4.350.0000.08018.91
5.4.340.0100.07019.09
5.4.320.0070.08019.24
5.4.310.0070.04719.09
5.4.300.0030.07719.03
5.4.290.0030.07019.13
5.4.280.0030.04718.85
5.4.270.0030.07319.12
5.4.260.0000.04019.18
5.4.250.0030.04018.84
5.4.240.0100.05719.15
5.4.230.0030.04719.04
5.4.220.0030.04019.13
5.4.210.0000.04019.18
5.4.200.0130.03719.04
5.4.190.0030.04318.94
5.4.180.0100.06319.02
5.4.170.0030.07719.11
5.4.160.0030.04019.20
5.4.150.0000.08019.03
5.4.140.0070.06716.45
5.4.130.0070.06016.41
5.4.120.0000.03716.18
5.4.110.0100.06016.42
5.4.100.0030.06016.47
5.4.90.0030.04016.47
5.4.80.0070.03016.41
5.4.70.0000.05016.41
5.4.60.0030.03716.29
5.4.50.0100.03016.24
5.4.40.0000.03316.30
5.4.30.0100.03016.48
5.4.20.0030.03316.36
5.4.10.0070.03716.40
5.4.00.0030.03315.91
5.3.290.0070.06314.73
5.3.280.0030.04014.54
5.3.270.0070.03314.55
5.3.260.0000.04014.55
5.3.250.0000.06714.66
5.3.240.0030.04714.67
5.3.230.0030.03314.71
5.3.220.0100.05014.66
5.3.210.0070.04014.53
5.3.200.0000.05014.66
5.3.190.0130.02714.62
5.3.180.0070.03714.66
5.3.170.0030.03314.63
5.3.160.0070.03714.67
5.3.150.0030.03714.55
5.3.140.0030.03714.56
5.3.130.0000.04014.57
5.3.120.0000.04014.64
5.3.110.0030.04314.48
5.3.100.0100.02714.16
5.3.90.0070.03714.13
5.3.80.0000.03314.16
5.3.70.0030.03014.14
5.3.60.0070.03013.98
5.3.50.0070.02714.04
5.3.40.0070.03313.95
5.3.30.0000.03314.00
5.3.20.0000.03013.69
5.3.10.0030.03013.77
5.3.00.0100.02713.78
5.2.170.0000.02711.28
5.2.160.0100.02011.17
5.2.150.0030.04011.16
5.2.140.0070.04311.04
5.2.130.0000.03011.09
5.2.120.0000.02710.98
5.2.110.0070.02011.21
5.2.100.0030.02311.11
5.2.90.0000.05311.21
5.2.80.0030.03711.11
5.2.70.0000.03311.16
5.2.60.0070.02710.98
5.2.50.0000.03011.13
5.2.40.0070.02311.00
5.2.30.0030.02711.08
5.2.20.0000.03010.98
5.2.10.0000.03010.98
5.2.00.0030.02310.98
5.1.60.0030.02310.98
5.1.50.0030.02310.98
5.1.40.0030.02310.98
5.1.30.0000.02710.98
5.1.20.0100.01310.98
5.1.10.0030.02010.98
5.1.00.0030.02310.98
5.0.50.0000.02010.98
5.0.40.0000.02310.98
5.0.30.0070.02310.98
5.0.20.0030.01310.98
5.0.10.0000.02010.98
5.0.00.0000.02710.98
4.4.90.0030.01310.98
4.4.80.0070.01010.98
4.4.70.0000.01310.98
4.4.60.0000.01310.98
4.4.50.0070.01010.98
4.4.40.0030.02310.98
4.4.30.0030.01310.98
4.4.20.0030.01310.98
4.4.10.0030.01310.98
4.4.00.0000.02310.98
4.3.110.0000.01710.98
4.3.100.0000.01310.98
4.3.90.0000.01310.98
4.3.80.0000.02310.98
4.3.70.0030.01010.98
4.3.60.0030.01010.98
4.3.50.0000.01310.98
4.3.40.0000.02010.98
4.3.30.0030.01010.98
4.3.20.0000.01710.98
4.3.10.0000.01310.98
4.3.00.0000.01310.98

preferences:
46.84 ms | 401 KiB | 5 Q