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 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.0140.00718.40
8.3.50.0090.01022.10
8.3.40.0120.00618.96
8.3.30.0030.01219.09
8.3.20.0070.00020.23
8.3.10.0040.00422.09
8.3.00.0040.00422.39
8.2.180.0040.01516.88
8.2.170.0100.01022.96
8.2.160.0150.00620.89
8.2.150.0040.00424.18
8.2.140.0090.00024.66
8.2.130.0000.00826.16
8.2.120.0040.00419.61
8.2.110.0070.00322.40
8.2.100.0120.00018.16
8.2.90.0070.00019.22
8.2.80.0030.00517.97
8.2.70.0000.00817.88
8.2.60.0000.00818.16
8.2.50.0000.00818.07
8.2.40.0080.00018.34
8.2.30.0070.00018.14
8.2.20.0000.00817.81
8.2.10.0040.00417.88
8.2.00.0040.00417.96
8.1.280.0090.00925.92
8.1.270.0040.00422.19
8.1.260.0060.00326.35
8.1.250.0040.00428.09
8.1.240.0100.00024.10
8.1.230.0100.00319.14
8.1.220.0030.00617.79
8.1.210.0030.00518.77
8.1.200.0060.00317.60
8.1.190.0000.01117.52
8.1.180.0040.00418.89
8.1.170.0000.00818.71
8.1.160.0000.00822.11
8.1.150.0000.00818.86
8.1.140.0000.00817.69
8.1.130.0000.00717.75
8.1.120.0030.00517.73
8.1.110.0000.00817.79
8.1.100.0000.00717.76
8.1.90.0080.00017.73
8.1.80.0000.00717.65
8.1.70.0030.00317.67
8.1.60.0050.00317.79
8.1.50.0000.00817.77
8.1.40.0040.00417.63
8.1.30.0080.00017.70
8.1.20.0000.00917.84
8.1.10.0040.00417.77
8.1.00.0040.00417.64
8.0.300.0080.00018.77
8.0.290.0000.00817.30
8.0.280.0000.00718.61
8.0.270.0040.00417.38
8.0.260.0070.00317.11
8.0.250.0000.00817.22
8.0.240.0020.00517.14
8.0.230.0000.00817.13
8.0.220.0030.00317.12
8.0.210.0030.00317.04
8.0.200.0040.00417.22
8.0.190.0020.01017.24
8.0.180.0000.00817.18
8.0.170.0040.00417.06
8.0.160.0050.00317.15
8.0.150.0040.00417.02
8.0.140.0080.00017.16
8.0.130.0000.00613.51
8.0.120.0040.00417.16
8.0.110.0070.00017.23
8.0.100.0000.00817.16
8.0.90.0000.00716.98
8.0.80.0060.00917.17
8.0.70.0000.00717.16
8.0.60.0000.00717.06
8.0.50.0000.00817.07
8.0.30.0150.00517.18
8.0.20.0090.01417.41
8.0.10.0080.00017.28
8.0.00.0120.01017.15
7.4.330.0050.00015.00
7.4.320.0030.00316.84
7.4.300.0000.00616.82
7.4.290.0030.00316.84
7.4.280.0030.00316.71
7.4.270.0070.00016.88
7.4.260.0080.00016.61
7.4.250.0000.00716.77
7.4.240.0000.00716.70
7.4.230.0000.00716.94
7.4.220.0090.01616.69
7.4.210.0120.00716.86
7.4.200.0070.00016.67
7.4.190.0000.00716.80
7.4.160.0150.00616.77
7.4.150.0100.00717.40
7.4.140.0140.00717.86
7.4.130.0120.00616.67
7.4.120.0090.01016.77
7.4.110.0030.01316.70
7.4.100.0070.01116.91
7.4.90.0090.01016.87
7.4.80.0070.01319.39
7.4.70.0150.00316.70
7.4.60.0070.01016.88
7.4.50.0050.00516.80
7.4.40.0060.01022.77
7.4.30.0080.00816.85
7.4.00.0120.00615.27
7.3.330.0030.00313.59
7.3.320.0000.00513.38
7.3.310.0040.00416.55
7.3.300.0040.00416.47
7.3.290.0060.00916.51
7.3.280.0050.01116.52
7.3.270.0100.00717.40
7.3.260.0150.00316.59
7.3.250.0050.01316.71
7.3.240.0160.00616.69
7.3.230.0090.00916.68
7.3.210.0060.01216.73
7.3.200.0100.00719.39
7.3.190.0150.00316.58
7.3.180.0110.00717.05
7.3.170.0100.00617.01
7.3.160.0080.00816.63
7.3.120.0070.00715.13
7.3.110.0140.00214.92
7.3.100.0100.00614.90
7.3.90.0090.00315.19
7.3.80.0070.00915.23
7.3.70.0040.01015.10
7.3.60.0080.00614.96
7.3.50.0060.00515.18
7.3.40.0020.01015.10
7.3.30.0080.00915.06
7.3.20.0110.00316.87
7.3.10.0050.00916.93
7.3.00.0080.00816.76
7.2.330.0170.00017.00
7.2.320.0130.00516.93
7.2.310.0090.00916.68
7.2.300.0030.01516.92
7.2.290.0130.01016.89
7.2.250.0110.00715.22
7.2.240.0090.01015.21
7.2.230.0060.00715.22
7.2.220.0050.00815.21
7.2.210.0080.01015.14
7.2.200.0080.00915.26
7.2.190.0060.00915.32
7.2.180.0100.00215.19
7.2.170.0070.00815.12
7.2.00.0000.01019.78
7.1.330.0070.00716.12
7.1.320.0040.00915.81
7.1.310.0030.01415.95
7.1.300.0080.00516.06
7.1.290.0050.00515.74
7.1.280.0050.00916.00
7.1.270.0060.00715.93
7.1.260.0060.00715.95
7.1.100.0040.01118.51
7.1.70.0070.00017.19
7.1.60.0030.01719.82
7.1.50.0000.01816.94
7.1.00.0070.07022.36
7.0.200.0050.00216.99
7.0.140.0070.07322.08
7.0.80.0130.06019.91
7.0.70.0100.07319.87
7.0.60.0130.07319.84
7.0.50.0170.06320.17
7.0.40.0070.08319.96
7.0.30.0130.06720.13
7.0.20.0070.08320.10
7.0.10.0070.07320.07
7.0.00.0070.08720.17
5.6.280.0000.07320.78
5.6.230.0130.08320.75
5.6.220.0070.08020.65
5.6.210.0130.08020.75
5.6.200.0030.09020.96
5.6.190.0130.08021.13
5.6.180.0170.07021.09
5.6.170.0030.07721.01
5.6.160.0070.08320.96
5.6.150.0030.09021.04
5.6.140.0100.06021.04
5.6.130.0070.07321.08
5.6.120.0170.05321.17
5.6.110.0100.07721.03
5.6.100.0070.05320.95
5.6.90.0200.07321.04
5.6.80.0030.06020.44
5.6.70.0100.04320.52
5.6.60.0100.06320.42
5.6.50.0130.07320.56
5.6.40.0170.06720.45
5.6.30.0230.06720.37
5.6.20.0170.07320.31
5.6.10.0200.06720.43
5.6.00.0100.05720.41
5.5.370.0000.08320.38
5.5.360.0030.08720.41
5.5.350.0130.07020.45
5.5.340.0130.07320.88
5.5.330.0130.07320.76
5.5.320.0100.04320.93
5.5.310.0000.05320.76
5.5.300.0130.07320.93
5.5.290.0100.05720.83
5.5.280.0070.04020.82
5.5.270.0070.09020.72
5.5.260.0130.06720.79
5.5.250.0030.08020.67
5.5.240.0130.06720.16
5.5.230.0100.06320.28
5.5.220.0070.07320.18
5.5.210.0070.06720.14
5.5.200.0130.06720.22
5.5.190.0170.06320.18
5.5.180.0100.08020.18
5.5.160.0230.04320.18
5.5.150.0130.04320.14
5.5.140.0070.07020.13
5.5.130.0130.07320.21
5.5.120.0030.08020.17
5.5.110.0030.07720.13
5.5.100.0170.05320.11
5.5.90.0170.04320.01
5.5.80.0070.04320.15
5.5.70.0070.05320.16
5.5.60.0170.05020.14
5.5.50.0130.06720.03
5.5.40.0100.07020.05
5.5.30.0130.07320.06
5.5.20.0070.08019.93
5.5.10.0100.07720.05
5.5.00.0030.08019.97
5.4.450.0100.05019.47
5.4.440.0070.08319.19
5.4.430.0130.07019.50
5.4.420.0100.07719.41
5.4.410.0070.07019.14
5.4.400.0100.07718.85
5.4.390.0030.07318.84
5.4.380.0030.06719.05
5.4.370.0130.07019.05
5.4.360.0230.06719.09
5.4.350.0130.07318.85
5.4.340.0130.07018.93
5.4.320.0100.06318.95
5.4.310.0130.06318.91
5.4.300.0100.06719.11
5.4.290.0100.04018.90
5.4.280.0100.06719.25
5.4.270.0170.06719.03
5.4.260.0130.07018.94
5.4.250.0070.05319.15
5.4.240.0130.07319.18
5.4.230.0030.04019.15
5.4.220.0030.06319.15
5.4.210.0030.05019.02
5.4.200.0030.04018.90
5.4.190.0130.03018.94
5.4.180.0100.04319.13
5.4.170.0070.04018.87
5.4.160.0030.06319.12
5.4.150.0100.04318.93
5.4.140.0070.07016.41
5.4.130.0030.06016.43
5.4.120.0070.07316.33
5.4.110.0030.06716.32
5.4.100.0200.06716.39
5.4.90.0070.07016.46
5.4.80.0030.05716.38
5.4.70.0100.06716.42
5.4.60.0000.04016.41
5.4.50.0100.05716.44
5.4.40.0070.03316.52
5.4.30.0030.03716.47
5.4.20.0100.06316.30
5.4.10.0000.05016.48
5.4.00.0030.03715.85
5.3.290.0030.05014.78
5.3.280.0100.06314.61
5.3.270.0070.05014.54
5.3.260.0130.06714.71
5.3.250.0100.04014.67
5.3.240.0100.04714.70
5.3.230.0130.07314.52
5.3.220.0030.07314.59
5.3.210.0130.07314.59
5.3.200.0070.08014.60
5.3.190.0100.07714.71
5.3.180.0030.06714.61
5.3.170.0130.07014.61
5.3.160.0030.05014.62
5.3.150.0100.03314.63
5.3.140.0070.07314.68
5.3.130.0000.04014.48
5.3.120.0030.04314.66
5.3.110.0100.03714.48
5.3.100.0030.04014.14
5.3.90.0030.04013.95
5.3.80.0030.04014.03
5.3.70.0030.03714.03
5.3.60.0000.04014.05
5.3.50.0100.03014.04
5.3.40.0000.04014.00
5.3.30.0000.03713.96
5.3.20.0070.03313.58
5.3.10.0030.06313.57
5.3.00.0170.06013.55
5.2.170.0070.02311.07
5.2.160.0030.02711.20
5.2.150.0000.03011.13
5.2.140.0030.03011.13
5.2.130.0000.03311.15
5.2.120.0000.04311.16
5.2.110.0030.06311.16
5.2.100.0130.04011.11
5.2.90.0000.04311.22
5.2.80.0000.06711.21
5.2.70.0070.06011.23
5.2.60.0100.01711.11
5.2.50.0030.03011.04
5.2.40.0030.04311.06
5.2.30.0000.03311.02
5.2.20.0000.02710.89
5.2.10.0030.03010.80
5.2.00.0030.02310.65
5.1.60.0000.02710.05
5.1.50.0030.0239.90
5.1.40.0000.02310.04
5.1.30.0000.04710.29
5.1.20.0030.03310.27
5.1.10.0000.0279.91
5.1.00.0000.03710.19
5.0.50.0070.0338.64
5.0.40.0000.0208.48
5.0.30.0000.0338.12
5.0.20.0000.0208.33
5.0.10.0030.0338.29
5.0.00.0000.0308.02
4.4.90.0000.0377.36
4.4.80.0030.0107.36
4.4.70.0000.0137.36
4.4.60.0000.0207.36
4.4.50.0000.0277.36
4.4.40.0030.0237.36
4.4.30.0070.0337.36
4.4.20.0030.0137.36
4.4.10.0000.0177.36
4.4.00.0030.0237.36
4.3.110.0000.0137.36
4.3.100.0000.0177.36
4.3.90.0000.0177.36
4.3.80.0030.0237.36
4.3.70.0000.0177.36
4.3.60.0000.0337.36
4.3.50.0000.0207.36
4.3.40.0000.0237.36
4.3.30.0000.0177.36
4.3.20.0000.0177.36
4.3.10.0030.0307.36
4.3.00.0000.0177.36

preferences:
63.78 ms | 400 KiB | 5 Q