3v4l.org

run code in 300+ PHP versions simultaneously
<?php function nextMonth($thisMonth, $monthInc) { $firstOfThis = date("Y-m", strtotime($thisMonth)); $dNow = date("t", strtotime($thisMonth)); $dNext = date("t", strtotime($firstOfThis . " +1 month")); $dDay = date("d", strtotime($thisMonth)); $output = date("Y-m-d",strtotime($thisMonth . " +1 month")); if ($dNext < $dNow && $dNext < $dDay) { $nextMonth = date("Y-m", strtotime($thisMonth)); $nextMonth = date("Y-m", strtotime($nextMonth . " +1 month")); $output = $nextMonth . '-' . $dNext; } return $output; } echo nextMonth("2010-01-31",1); $sample1 = "2010-01-31"; $sample1a = "2010-01-01"; $dnow = date("t",strtotime($sample1)); $dnext = date("t",strtotime($sample1a . " +1 month")); $dday = date("d",strtotime($sample1)); $output = date("Y-m-d",strtotime($sample1 . " +1 month")); echo '/' . $dnow . '/' . $dnext . '/' . $dday . '/'; echo "\n"; if ($dnext < $dnow && $dnext < $dday) { $nextMonth = date("Y-m", strtotime($sample1)); $nextMonth = date("Y-m", strtotime($nextMonth . " +1 month")); $output = $nextMonth . '-' . $dnext; } echo $output; echo "\n"; $ts = strtotime('2010-01-31 +1 month'); echo date('Y-m-d', $ts); echo "\n"; $dt = new \DateTime('2010-01-31'); $dt->add(new \DateInterval('P1M')); echo $dt->format('Y-m-d'); echo "\n"; $ts = strtotime('2010-01-05 +1 month'); echo date('Y-m-d', $ts); echo "\n"; $dt = new \DateTime('2010-01-05'); $dt->add(new \DateInterval('P1M')); echo $dt->format('Y-m-d');

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.0050.01121.14
8.3.40.0110.00418.96
8.3.30.0140.00020.39
8.3.20.0080.00020.66
8.3.10.0040.00421.14
8.3.00.0040.00423.71
8.2.180.0120.00617.00
8.2.170.0150.00022.96
8.2.160.0000.01420.35
8.2.150.0080.00024.18
8.2.140.0040.00424.66
8.2.130.0070.00026.16
8.2.120.0080.00021.07
8.2.110.0130.00719.51
8.2.100.0120.00018.03
8.2.90.0050.00319.30
8.2.80.0080.00018.05
8.2.70.0070.00317.75
8.2.60.0040.00417.93
8.2.50.0080.00018.07
8.2.40.0030.00518.34
8.2.30.0040.00421.29
8.2.20.0040.00417.96
8.2.10.0030.00618.06
8.2.00.0080.00018.00
8.1.280.0070.00725.92
8.1.270.0050.00223.99
8.1.260.0060.00326.35
8.1.250.0000.00728.09
8.1.240.0040.00722.49
8.1.230.0080.00320.83
8.1.220.0000.00818.77
8.1.210.0090.00319.16
8.1.200.0060.00617.48
8.1.190.0040.00417.63
8.1.180.0030.00518.10
8.1.170.0080.00318.84
8.1.160.0040.00419.11
8.1.150.0040.00418.99
8.1.140.0040.00417.77
8.1.130.0000.00718.06
8.1.120.0000.00817.81
8.1.110.0070.00017.80
8.1.100.0000.00817.76
8.1.90.0000.00817.68
8.1.80.0040.00417.81
8.1.70.0070.00017.65
8.1.60.0040.00417.74
8.1.50.0050.00317.63
8.1.40.0040.00417.74
8.1.30.0040.00417.86
8.1.20.0030.00617.72
8.1.10.0000.00817.80
8.1.00.0050.00317.80
8.0.300.0080.00020.10
8.0.290.0040.00417.43
8.0.280.0040.00418.63
8.0.270.0060.00317.37
8.0.260.0060.00017.06
8.0.250.0040.00417.30
8.0.240.0030.00717.23
8.0.230.0000.00717.16
8.0.220.0000.00717.21
8.0.210.0030.00317.08
8.0.200.0060.00017.24
8.0.190.0040.00417.24
8.0.180.0000.00817.25
8.0.170.0040.00417.21
8.0.160.0020.00517.26
8.0.150.0030.00517.21
8.0.140.0030.00717.11
8.0.130.0000.00613.54
8.0.120.0000.00817.24
8.0.110.0000.00717.23
8.0.100.0040.00417.23
8.0.90.0040.00417.21
8.0.80.0110.00717.25
8.0.70.0000.00817.17
8.0.60.0000.00717.19
8.0.50.0050.00216.99
8.0.30.0150.00517.44
8.0.20.0080.01117.40
8.0.10.0000.00817.28
8.0.00.0060.01216.96
7.4.330.0000.00515.16
7.4.320.0000.00716.84
7.4.300.0000.00616.66
7.4.290.0000.00716.84
7.4.280.0080.00016.78
7.4.270.0040.00416.83
7.4.260.0000.00513.47
7.4.250.0030.00516.70
7.4.240.0000.00716.84
7.4.230.0000.00816.85
7.4.220.0040.02016.77
7.4.210.0070.00916.79
7.4.200.0000.00716.80
7.4.190.0080.00016.89
7.4.160.0110.00516.57
7.4.150.0130.00617.40
7.4.140.0140.00617.86
7.4.130.0050.01216.93
7.4.120.0080.01116.82
7.4.110.0030.01416.81
7.4.100.0110.00816.82
7.4.90.0170.00316.97
7.4.80.0030.01519.39
7.4.70.0040.01516.61
7.4.60.0100.01016.67
7.4.50.0060.00316.84
7.4.40.0120.00022.77
7.4.30.0140.00316.68
7.4.00.0000.01615.13
7.3.330.0030.00313.31
7.3.320.0000.00513.34
7.3.310.0070.00016.54
7.3.300.0030.00316.55
7.3.290.0070.00716.54
7.3.280.0110.00616.53
7.3.270.0060.01217.40
7.3.260.0100.00918.24
7.3.250.0110.00816.75
7.3.240.0030.01516.62
7.3.230.0060.01316.95
7.3.210.0090.00916.49
7.3.200.0090.01219.39
7.3.190.0160.00216.74
7.3.180.0080.00816.87
7.3.170.0060.01116.71
7.3.160.0080.01316.53
7.3.120.0030.00915.40
7.3.10.0050.00516.98
7.3.00.0070.00316.77
7.2.330.0110.00717.09
7.2.320.0060.01216.79
7.2.310.0130.00517.07
7.2.300.0070.01117.12
7.2.290.0130.01017.12
7.2.130.0000.01217.25
7.2.120.0070.00317.29
7.2.110.0040.00717.04
7.2.100.0110.00017.32
7.2.90.0040.00417.36
7.2.80.0070.00416.95
7.2.70.0060.00617.35
7.2.60.0090.00317.06
7.2.50.0040.00717.33
7.2.40.0030.00717.02
7.2.30.0030.00717.33
7.2.20.0030.00617.26
7.2.10.0030.00917.28
7.2.00.0060.00617.36
7.1.250.0030.00316.08
7.1.200.0170.00316.15
7.1.70.0070.01017.21
7.1.60.0060.01319.17
7.1.50.0130.00716.98
7.1.00.0000.06722.28
7.0.200.0050.00317.00
7.0.140.0000.07722.07
7.0.80.0200.04020.00
7.0.70.0570.07019.99
7.0.60.0330.04319.89
7.0.50.0500.08720.20
7.0.40.0030.07019.95
7.0.30.0100.08020.11
7.0.20.0170.08020.09
7.0.10.0070.08720.02
7.0.00.0030.09020.07
5.6.280.0000.07721.14
5.6.230.0070.06320.52
5.6.220.0070.04020.57
5.6.210.0070.05320.76
5.6.200.0200.04720.97
5.6.190.0070.04721.15
5.6.180.0230.06720.95
5.6.170.0130.07021.06
5.6.160.0070.08321.04
5.6.150.0100.08321.15
5.6.140.0100.06721.03
5.6.130.0070.08320.97
5.6.120.0170.07721.05
5.6.110.0030.08321.04
5.6.100.0070.04721.12
5.6.90.0030.07721.11
5.6.80.0100.07320.51
5.6.70.0100.08020.41
5.6.60.0100.05020.43
5.6.50.0000.09020.43
5.6.40.0170.07320.41
5.6.30.0170.07320.46
5.6.20.0100.07720.41
5.6.10.0000.08720.41
5.6.00.0000.08720.52
5.5.370.0000.04320.37
5.5.360.0100.03720.37
5.5.350.0130.07720.45
5.5.340.0100.08020.81
5.5.330.0100.07720.91
5.5.320.0100.06020.92
5.5.310.0000.08720.84
5.5.300.0100.07720.89
5.5.290.0030.08020.89
5.5.280.0030.09020.92
5.5.270.0070.08020.89
5.5.260.0200.07020.81
5.5.250.0130.07320.67
5.5.240.0000.06320.27
5.5.230.0100.06720.23
5.5.220.0070.06020.22
5.5.210.0100.07720.22
5.5.200.0070.08020.25
5.5.190.0100.08020.16
5.5.180.0070.07720.25
5.5.160.0000.08320.28
5.5.150.0130.07020.17
5.5.140.0100.07320.26
5.5.130.0070.05320.24
5.5.120.0000.08320.22
5.5.110.0070.06720.28
5.5.100.0200.06020.09
5.5.90.0100.06720.09
5.5.80.0170.07320.16
5.5.70.0030.07720.07
5.5.60.0100.07320.12
5.5.50.0070.04020.16
5.5.40.0030.08019.92
5.5.30.0030.04020.05
5.5.20.0070.03720.01
5.5.10.0100.07320.06
5.5.00.0070.04019.98
5.4.450.0100.04719.46
5.4.440.0130.07319.55
5.4.430.0070.05719.41
5.4.420.0070.05319.39
5.4.410.0030.04719.32
5.4.400.0030.08019.14
5.4.390.0000.08318.92
5.4.380.0130.03319.09
5.4.370.0100.07319.13
5.4.360.0100.07718.85
5.4.350.0070.07319.12
5.4.340.0030.08018.95
5.4.320.0030.06018.95
5.4.310.0070.05319.05
5.4.300.0130.06019.08
5.4.290.0030.08019.02
5.4.280.0030.04319.18
5.4.270.0130.07719.13
5.4.260.0030.07719.23
5.4.250.0070.04019.13
5.4.240.0100.07018.84
5.4.230.0100.05019.08
5.4.220.0100.07319.13
5.4.210.0130.07318.89
5.4.200.0030.04018.87
5.4.190.0100.03719.22
5.4.180.0070.07318.93
5.4.170.0030.08318.93
5.4.160.0070.04019.21
5.4.150.0000.03719.16
5.4.140.0000.04316.42
5.4.130.0170.06316.20
5.4.120.0070.04016.32
5.4.110.0030.05016.35
5.4.100.0030.08316.43
5.4.90.0200.06016.30
5.4.80.0030.06716.46
5.4.70.0070.06016.34
5.4.60.0170.04716.45
5.4.50.0000.04716.34
5.4.40.0000.05316.42
5.4.30.0030.07716.36
5.4.20.0030.06316.44
5.4.10.0300.05016.30
5.4.00.0100.07315.91
5.3.290.0100.06714.75
5.3.280.0030.08014.60
5.3.270.0000.03714.71
5.3.260.0000.04014.59
5.3.250.0130.02014.69
5.3.240.0030.07714.75
5.3.230.0000.07714.64
5.3.220.0100.03714.52
5.3.210.0070.07314.55
5.3.200.0030.04314.64
5.3.190.0130.07014.73
5.3.180.0130.04014.69
5.3.170.0070.05714.52
5.3.160.0030.07014.63
5.3.150.0130.06714.61
5.3.140.0100.07314.56
5.3.130.0030.07014.63
5.3.120.0070.06014.64
5.3.110.0100.04714.68
5.3.100.0100.04313.98
5.3.90.0030.07714.01
5.3.80.0130.05313.92
5.3.70.0130.06714.01
5.3.60.0070.05314.13
5.3.50.0100.07013.95
5.3.40.0070.04713.95
5.3.30.0130.06713.82
5.3.20.0070.07313.73
5.3.10.0070.07013.68
5.3.00.0030.06313.59
5.2.170.0000.04711.18
5.2.160.0130.02711.25
5.2.150.0070.06011.15
5.2.140.0070.05011.02
5.2.130.0000.05311.00
5.2.120.0030.06311.18
5.2.110.0070.06011.21
5.2.100.0030.04011.22
5.2.90.0030.06711.28
5.2.80.0070.06711.20
5.2.70.0070.06011.11
5.2.60.0030.05711.18
5.2.50.0070.04711.10
5.2.40.0030.05011.03
5.2.30.0030.05711.00
5.2.20.0130.04711.09
5.2.10.0070.06010.87
5.2.00.0030.06010.77
5.1.60.0000.0579.88
5.1.50.0030.03310.04
5.1.40.0030.05310.10
5.1.30.0070.05310.48
5.1.20.0100.05010.46
5.1.10.0070.05010.14
5.1.00.0070.05310.08
5.0.50.0130.0338.70
5.0.40.0000.0378.51
5.0.30.0200.0408.38
5.0.20.0100.0338.32
5.0.10.0000.0478.20
5.0.00.0030.0678.23
4.4.90.0070.0307.09
4.4.80.0000.0377.09
4.4.70.0070.0237.09
4.4.60.0070.0277.09
4.4.50.0030.0277.09
4.4.40.0000.0577.09
4.4.30.0000.0377.09
4.4.20.0030.0337.09
4.4.10.0030.0337.09
4.4.00.0000.0507.09
4.3.110.0000.0307.09
4.3.100.0030.0337.09
4.3.90.0030.0337.09
4.3.80.0030.0537.09
4.3.70.0000.0277.09
4.3.60.0000.0277.09
4.3.50.0000.0237.09
4.3.40.0000.0537.09
4.3.30.0000.0277.09
4.3.20.0000.0377.09
4.3.10.0000.0237.09
4.3.00.0030.0337.09

preferences:
47.04 ms | 401 KiB | 5 Q