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 " . date('Y-m', $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.0170.00318.68
8.3.50.0070.01221.92
8.3.40.0070.01118.97
8.3.30.0110.00319.22
8.3.20.0000.00820.16
8.3.10.0040.00422.04
8.3.00.0080.00022.58
8.2.180.0110.00716.75
8.2.170.0130.00722.96
8.2.160.0090.00621.07
8.2.150.0060.00324.18
8.2.140.0080.00024.66
8.2.130.0030.00526.16
8.2.120.0030.00519.61
8.2.110.0030.00622.06
8.2.100.0110.00019.70
8.2.90.0000.00819.20
8.2.80.0040.00417.97
8.2.70.0040.00417.63
8.2.60.0060.00318.05
8.2.50.0060.00318.07
8.2.40.0030.00518.34
8.2.30.0000.00918.21
8.2.20.0060.00317.91
8.2.10.0050.00218.01
8.2.00.0000.00817.95
8.1.280.0100.01025.92
8.1.270.0050.00322.23
8.1.260.0070.00026.35
8.1.250.0040.00428.09
8.1.240.0100.00023.96
8.1.230.0030.00919.15
8.1.220.0040.00417.78
8.1.210.0080.00018.77
8.1.200.0100.00017.61
8.1.190.0030.00617.55
8.1.180.0040.00418.73
8.1.170.0030.00518.74
8.1.160.0000.00822.11
8.1.150.0000.00718.79
8.1.140.0050.00317.73
8.1.130.0080.00017.82
8.1.120.0000.00717.60
8.1.110.0000.00717.64
8.1.100.0000.00717.74
8.1.90.0050.00517.71
8.1.80.0040.00417.75
8.1.70.0000.00817.63
8.1.60.0000.00817.77
8.1.50.0030.00517.72
8.1.40.0090.00017.77
8.1.30.0040.00417.67
8.1.20.0050.00317.82
8.1.10.0050.00317.59
8.1.00.0070.00317.59
8.0.300.0060.00318.77
8.0.290.0030.00617.30
8.0.280.0030.00318.61
8.0.270.0030.00517.43
8.0.260.0070.00317.08
8.0.250.0000.00817.23
8.0.240.0040.00417.21
8.0.230.0040.00417.24
8.0.220.0030.00317.13
8.0.210.0030.00417.16
8.0.200.0000.00817.13
8.0.190.0030.00517.20
8.0.180.0050.00317.13
8.0.170.0040.00417.18
8.0.160.0000.00817.24
8.0.150.0040.00417.11
8.0.140.0000.00717.05
8.0.130.0000.00513.60
8.0.120.0040.00417.11
8.0.110.0040.00417.00
8.0.100.0070.00017.00
8.0.90.0040.00417.08
8.0.80.0080.00717.17
8.0.70.0040.00417.17
8.0.60.0000.00717.13
8.0.50.0030.00517.22
8.0.30.0110.00717.31
8.0.20.0080.01417.43
8.0.10.0070.00017.33
8.0.00.0160.00816.93
7.4.330.0030.00315.00
7.4.320.0060.00016.77
7.4.300.0000.00616.79
7.4.290.0070.00016.84
7.4.280.0040.00316.62
7.4.270.0030.00516.66
7.4.260.0040.00416.76
7.4.250.0070.00016.76
7.4.240.0070.00016.78
7.4.230.0040.00416.85
7.4.220.0160.00716.83
7.4.210.0050.01016.82
7.4.200.0070.00016.87
7.4.190.0050.00316.91
7.4.160.0140.00716.90
7.4.150.0060.01317.40
7.4.140.0090.00917.86
7.4.130.0090.01116.70
7.4.120.0120.00816.92
7.4.110.0140.00316.70
7.4.100.0160.00316.81
7.4.90.0090.01116.79
7.4.80.0070.01719.39
7.4.70.0070.01016.67
7.4.60.0030.01316.85
7.4.50.0070.00016.75
7.4.40.0070.01122.77
7.4.30.0040.01216.80
7.4.00.0040.01115.33
7.3.330.0000.00613.50
7.3.320.0000.00613.33
7.3.310.0040.00416.48
7.3.300.0000.00716.57
7.3.290.0060.00916.57
7.3.280.0060.00916.47
7.3.270.0060.01117.40
7.3.260.0160.00316.93
7.3.250.0080.01216.75
7.3.240.0150.00916.46
7.3.230.0060.01016.83
7.3.210.0100.01016.88
7.3.200.0070.01019.39
7.3.190.0120.00916.78
7.3.180.0110.00716.68
7.3.170.0090.00916.77
7.3.160.0050.01116.80
7.3.120.0070.00714.99
7.2.330.0060.01216.62
7.2.320.0100.00917.05
7.2.310.0170.00017.06
7.2.300.0040.01516.98
7.2.290.0150.00916.83
7.2.60.0120.00417.09
7.2.50.0100.00317.14
7.1.200.0280.00415.98
7.1.70.0060.00317.18
7.1.60.0070.01019.82
7.1.50.0030.01617.09
7.1.00.0000.08022.54
7.0.200.0030.00517.07
7.0.140.0000.07721.92
7.0.100.0000.08722.00
7.0.90.0100.07021.76
7.0.80.0030.05721.71
7.0.70.0000.08321.68
7.0.60.0130.07021.77
7.0.50.0100.04022.11
7.0.40.0070.06320.05
7.0.30.0070.08320.05
7.0.20.0100.07320.05
7.0.10.0000.08720.07
7.0.00.0170.07320.10
5.6.280.0000.07720.91
5.6.250.0030.04720.54
5.6.240.0030.06020.59
5.6.230.0030.08320.71
5.6.220.0030.08020.48
5.6.210.0100.07320.58
5.6.200.0200.07320.97
5.6.190.0030.08721.08
5.6.180.0130.07321.04
5.6.170.0000.08321.18
5.6.160.0030.08020.94
5.6.150.0070.08021.11
5.6.140.0100.07720.95
5.6.130.0100.08021.08
5.6.120.0030.08020.96
5.6.110.0030.06021.04
5.6.100.0100.08021.05
5.6.90.0030.07721.00
5.6.80.0070.08020.41
5.6.70.0070.06320.31
5.6.60.0070.06020.45
5.6.50.0000.06320.44
5.6.40.0000.04320.50
5.6.30.0000.04720.31
5.6.20.0070.05020.31
5.6.10.0030.04320.38
5.6.00.0030.07720.41
5.5.380.0070.08020.39
5.5.370.0070.08020.36
5.5.360.0070.07720.48
5.5.350.0030.08720.39
5.5.340.0100.05020.89
5.5.330.0030.07720.86
5.5.320.0030.08320.93
5.5.310.0000.05720.64
5.5.300.0030.08020.80
5.5.290.0070.08020.88
5.5.280.0070.07720.89
5.5.270.0100.07020.88
5.5.260.0030.07720.87
5.5.250.0130.06720.70
5.5.240.0000.05720.16
5.5.230.0070.08020.02
5.5.220.0070.06020.30
5.5.210.0000.08320.11
5.5.200.0000.08020.13
5.5.190.0070.08019.96
5.5.180.0070.07720.23
5.5.160.0000.04720.28
5.5.150.0100.07320.15
5.5.140.0030.08020.14
5.5.130.0030.08320.00
5.5.120.0030.08319.99
5.5.110.0030.08320.18
5.5.100.0030.07320.07
5.5.90.0070.07719.97
5.5.80.0070.07020.10
5.5.70.0070.06720.09
5.5.60.0070.08020.06
5.5.50.0100.07020.05
5.5.40.0000.06320.05
5.5.30.0030.08020.10
5.5.20.0030.07720.05
5.5.10.0070.08319.96
5.5.00.0100.07020.07
5.4.450.0070.07019.38
5.4.440.0070.06719.35
5.4.430.0070.06719.22
5.4.420.0030.08319.48
5.4.410.0070.07319.32
5.4.400.0100.07019.23
5.4.390.0000.08319.23
5.4.380.0000.07719.23
5.4.370.0000.08019.16
5.4.360.0000.07019.16
5.4.350.0000.04019.09
5.4.340.0100.06719.18
5.4.320.0030.08019.03
5.4.310.0000.07319.03
5.4.300.0030.06018.95
5.4.290.0030.06018.94
5.4.280.0100.06719.13
5.4.270.0070.07318.87
5.4.260.0070.06319.03
5.4.250.0030.07719.22
5.4.240.0000.08019.08
5.4.230.0030.07719.03
5.4.220.0070.07719.18
5.4.210.0070.06318.91
5.4.200.0100.06719.03
5.4.190.0100.07719.22
5.4.180.0070.07318.89
5.4.170.0070.07318.87
5.4.160.0000.08018.88
5.4.150.0000.06019.02
5.4.140.0070.04716.37
5.4.130.0070.04016.28
5.4.120.0000.07716.39
5.4.110.0030.06716.33
5.4.100.0100.06716.40
5.4.90.0030.07316.36
5.4.80.0000.05316.30
5.4.70.0030.07316.47
5.4.60.0070.07016.37
5.4.50.0070.07316.33
5.4.40.0030.04716.41
5.4.30.0100.06716.45
5.4.20.0000.07716.33
5.4.10.0000.03716.46
5.4.00.0030.03315.82
5.3.290.0030.05014.62
5.3.280.0000.08014.69
5.3.270.0030.07014.67
5.3.260.0030.07714.61
5.3.250.0030.07314.61
5.3.240.0070.07014.73
5.3.230.0000.06714.53
5.3.220.0000.06314.64
5.3.210.0030.08314.50
5.3.200.0000.08014.55
5.3.190.0030.07014.71
5.3.180.0030.05014.56
5.3.170.0100.07014.68
5.3.160.0000.08014.52
5.3.150.0000.07714.55
5.3.140.0030.06314.55
5.3.130.0000.04714.50
5.3.120.0100.07314.61
5.3.110.0000.04314.47
5.3.100.0000.04314.01
5.3.90.0000.07714.13
5.3.80.0070.08314.13
5.3.70.0030.05713.92
5.3.60.0000.03713.98
5.3.50.0030.07713.87
5.3.40.0070.07013.97
5.3.30.0070.07013.91
5.3.20.0000.06713.68
5.3.10.0000.03713.67
5.3.00.0000.04313.74
5.2.170.0030.06711.06
5.2.160.0030.04311.21
5.2.150.0000.06311.23
5.2.140.0030.06311.21
5.2.130.0030.05711.11
5.2.120.0030.04711.13
5.2.110.0070.03711.13
5.2.100.0030.03011.16
5.2.90.0000.06310.96
5.2.80.0070.04311.16
5.2.70.0000.06310.96
5.2.60.0000.06711.10
5.2.50.0030.06311.07
5.2.40.0000.06310.91
5.2.30.0030.05710.88
5.2.20.0000.06311.05
5.2.10.0030.05710.76
5.2.00.0070.05710.85
5.1.60.0000.0509.84
5.1.50.0030.04010.08
5.1.40.0000.0539.97
5.1.30.0070.04310.25
5.1.20.0030.06010.45
5.1.10.0030.04310.18
5.1.00.0030.03710.06
5.0.50.0000.0339.26
5.0.40.0000.0439.26
5.0.30.0030.0709.26
5.0.20.0000.0479.26
5.0.10.0030.0279.26
5.0.00.0000.0679.26
4.4.90.0000.0379.26
4.4.80.0000.0339.26
4.4.70.0030.0339.26
4.4.60.0030.0279.26
4.4.50.0030.0279.26
4.4.40.0070.0479.26
4.4.30.0030.0339.26
4.4.20.0030.0209.26
4.4.10.0070.0239.26
4.4.00.0030.0539.26
4.3.110.0000.0209.26
4.3.100.0030.0309.26
4.3.90.0000.0279.26
4.3.80.0000.0479.26
4.3.70.0000.0379.26
4.3.60.0000.0379.26
4.3.50.0070.0309.26
4.3.40.0000.0339.26
4.3.30.0030.0309.26
4.3.20.0000.0379.26
4.3.10.0070.0309.26
4.3.00.0030.0239.26

preferences:
45.85 ms | 401 KiB | 5 Q