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 . " +" . $monthInc . " month")); $dDay = date("d", strtotime($thisMonth)); $output = date("Y-m-d",strtotime($thisMonth . " +" . $monthInc . " month")); if ($dNext < $dNow && $dNext < $dDay) { $nextMonth = date("Y-m", strtotime($thisMonth)); $nextMonth = date("Y-m", strtotime($nextMonth . " +" . $monthInc . " month")); $output = $nextMonth . '-' . $dNext; } return $output; } echo nextMonth("2010-01-31",1); exit(); $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.0090.00618.63
8.3.50.0120.01022.13
8.3.40.0070.01118.92
8.3.30.0040.01119.01
8.3.20.0050.00320.33
8.3.10.0050.00323.56
8.3.00.0050.00320.79
8.2.180.0120.00416.50
8.2.170.0070.00722.96
8.2.160.0000.01422.08
8.2.150.0000.00824.18
8.2.140.0080.00024.66
8.2.130.0070.00026.16
8.2.120.0040.00422.33
8.2.110.0070.00422.28
8.2.100.0040.00817.97
8.2.90.0040.00418.00
8.2.80.0090.00017.97
8.2.70.0060.00317.93
8.2.60.0040.00418.16
8.2.50.0030.00618.15
8.2.40.0040.00420.59
8.2.30.0040.00418.29
8.2.20.0030.00517.99
8.2.10.0040.00417.93
8.2.00.0040.00418.04
8.1.280.0090.00625.92
8.1.270.0040.00423.95
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0090.00023.83
8.1.230.0110.00019.27
8.1.220.0000.00817.91
8.1.210.0030.00618.77
8.1.200.0040.00417.73
8.1.190.0040.00817.72
8.1.180.0050.00318.10
8.1.170.0040.00418.96
8.1.160.0030.00622.13
8.1.150.0080.00018.98
8.1.140.0000.00817.82
8.1.130.0000.00717.97
8.1.120.0040.00417.79
8.1.110.0030.00617.82
8.1.100.0070.00017.66
8.1.90.0060.00317.78
8.1.80.0030.00317.79
8.1.70.0000.00717.57
8.1.60.0080.00017.84
8.1.50.0060.00317.77
8.1.40.0040.00417.70
8.1.30.0030.00617.70
8.1.20.0000.00717.88
8.1.10.0030.00617.80
8.1.00.0030.00517.78
8.0.300.0000.00821.70
8.0.290.0040.00417.00
8.0.280.0000.00718.64
8.0.270.0040.00417.45
8.0.260.0030.00317.17
8.0.250.0070.00017.27
8.0.240.0000.00817.28
8.0.230.0000.00717.32
8.0.220.0030.00317.21
8.0.210.0000.00817.19
8.0.200.0050.00217.22
8.0.190.0000.00817.27
8.0.180.0070.00017.20
8.0.170.0040.00417.37
8.0.160.0070.00017.30
8.0.150.0040.00417.17
8.0.140.0040.00417.14
8.0.130.0000.00613.63
8.0.120.0050.00317.19
8.0.110.0040.00417.20
8.0.100.0040.00417.07
8.0.90.0060.00317.29
8.0.80.0060.00917.29
8.0.70.0050.00317.14
8.0.60.0040.00417.25
8.0.50.0000.00717.30
8.0.30.0060.01217.35
8.0.20.0140.00417.51
8.0.10.0050.00317.31
8.0.00.0100.01117.08
7.4.330.0000.00515.09
7.4.320.0000.00716.68
7.4.300.0070.00016.75
7.4.290.0040.00716.71
7.4.280.0030.00316.77
7.4.270.0030.00316.71
7.4.260.0070.00016.75
7.4.250.0000.00716.81
7.4.240.0040.00416.77
7.4.230.0000.00716.60
7.4.220.0030.01516.63
7.4.210.0090.00916.83
7.4.200.0050.00216.75
7.4.190.0030.00316.64
7.4.160.0060.00916.95
7.4.150.0100.01017.40
7.4.140.0080.01117.86
7.4.130.0080.01016.91
7.4.120.0100.01116.82
7.4.110.0030.01416.93
7.4.100.0120.01216.84
7.4.90.0130.01317.04
7.4.80.0070.01116.78
7.4.70.0120.00616.86
7.4.60.0030.01316.82
7.4.50.0050.00316.73
7.4.40.0060.00922.77
7.4.30.0080.00816.86
7.4.00.0080.01015.26
7.3.330.0030.00313.59
7.3.320.0050.00013.62
7.3.310.0070.00016.57
7.3.300.0030.00316.52
7.3.290.0040.01116.60
7.3.280.0090.00616.60
7.3.270.0080.01217.40
7.3.260.0060.01216.67
7.3.250.0070.01016.89
7.3.240.0150.00316.84
7.3.230.0100.00616.69
7.3.210.0030.01516.80
7.3.200.0130.00619.39
7.3.190.0120.00816.59
7.3.180.0100.00716.74
7.3.170.0000.01616.79
7.3.160.0060.00916.83
7.3.120.0110.00715.17
7.3.110.0030.01315.30
7.3.100.0100.00715.26
7.3.90.0060.00614.94
7.3.80.0070.01015.13
7.3.70.0070.00415.23
7.3.60.0070.00315.06
7.3.50.0030.00714.87
7.3.40.0130.00015.07
7.3.30.0060.00614.96
7.3.20.0060.00616.89
7.3.10.0070.00716.99
7.3.00.0050.00916.92
7.2.330.0070.01616.87
7.2.320.0030.01416.75
7.2.310.0030.01317.04
7.2.300.0070.01116.89
7.2.290.0090.00916.90
7.2.250.0060.01215.52
7.2.240.0100.01015.54
7.2.230.0040.01515.21
7.2.220.0040.01115.55
7.2.210.0030.01015.49
7.2.200.0030.01015.29
7.2.190.0090.00615.34
7.2.180.0100.00715.44
7.2.170.0100.00715.29
7.2.130.0030.01017.23
7.2.120.0060.00917.21
7.2.110.0050.00517.07
7.2.100.0000.01217.16
7.2.90.0070.01017.26
7.2.80.0090.00917.09
7.2.70.0070.00317.21
7.2.60.0070.00717.04
7.2.50.0090.00617.17
7.2.40.0100.00717.17
7.2.30.0090.00617.00
7.2.20.0030.01017.32
7.2.10.0030.00717.28
7.2.00.0030.00818.47
7.1.330.0030.01315.89
7.1.320.0070.00715.73
7.1.310.0070.00715.98
7.1.300.0040.00416.16
7.1.290.0030.01016.09
7.1.280.0030.01516.03
7.1.270.0080.00416.10
7.1.260.0000.01016.04
7.1.250.0080.00016.06
7.1.100.0040.01118.34
7.1.70.0090.00017.59
7.1.60.0100.01019.29
7.1.50.0090.01217.29
7.1.00.0030.07722.32
7.0.200.0080.00416.81
7.0.140.0100.06722.01
7.0.100.0100.03720.05
7.0.90.0170.04319.91
7.0.80.0170.03320.16
7.0.70.0100.03720.02
7.0.60.0130.07319.95
7.0.50.0170.03020.32
7.0.40.0000.04720.14
7.0.30.0100.04020.15
7.0.20.0070.05719.95
7.0.10.0030.07720.07
7.0.00.0030.04720.13
5.6.280.0070.07021.09
5.6.250.0030.03720.60
5.6.240.0070.03320.61
5.6.230.0130.03020.58
5.6.220.0030.03320.57
5.6.210.0030.04320.66
5.6.200.0030.03721.04
5.6.190.0070.07720.98
5.6.180.0100.06321.19
5.6.170.0070.04021.04
5.6.160.0070.04021.08
5.6.150.0170.03321.09
5.6.140.0000.05321.04
5.6.130.0130.06321.12
5.6.120.0170.02721.09
5.6.110.0100.03321.17
5.6.100.0100.07321.14
5.6.90.0030.04020.99
5.6.80.0000.04020.54
5.6.70.0070.06720.31
5.6.60.0000.05720.47
5.6.50.0030.03720.49
5.6.40.0030.03720.41
5.6.30.0100.05720.39
5.6.20.0000.04020.48
5.6.10.0030.06020.45
5.6.00.0000.04320.34
5.5.380.0100.03320.43
5.5.370.0030.04020.38
5.5.360.0070.03320.46
5.5.350.0000.03720.47
5.5.340.0070.03020.89
5.5.330.0070.03720.81
5.5.320.0070.07320.94
5.5.310.0070.07720.61
5.5.300.0100.05320.80
5.5.290.0070.08720.89
5.5.280.0030.06320.93
5.5.270.0030.05320.93
5.5.260.0030.04020.65
5.5.250.0030.07720.45
5.5.240.0100.07720.33
5.5.230.0130.06720.32
5.5.220.0070.03020.20
5.5.210.0170.06720.27
5.5.200.0200.02020.25
5.5.190.0070.07720.20
5.5.180.0030.08020.24
5.5.160.0030.04020.16
5.5.150.0100.03020.22
5.5.140.0100.05320.09
5.5.130.0100.08320.27
5.5.120.0070.06320.16
5.5.110.0000.07020.19
5.5.100.0030.05020.14
5.5.90.0070.08020.06
5.5.80.0100.07019.99
5.5.70.0070.08019.95
5.5.60.0070.03720.07
5.5.50.0130.05720.07
5.5.40.0130.03320.10
5.5.30.0100.03020.10
5.5.20.0070.03320.15
5.5.10.0070.06320.14
5.5.00.0070.07320.05
5.4.450.0000.04719.55
5.4.440.0030.03719.36
5.4.430.0170.04019.44
5.4.420.0000.07719.22
5.4.410.0070.08719.23
5.4.400.0070.03019.18
5.4.390.0030.07019.18
5.4.380.0070.07319.21
5.4.370.0070.08019.09
5.4.360.0070.03019.13
5.4.350.0000.04018.95
5.4.340.0130.03319.03
5.4.320.0030.04019.03
5.4.310.0100.06319.07
5.4.300.0000.03718.89
5.4.290.0030.08019.03
5.4.280.0030.03718.96
5.4.270.0030.03319.22
5.4.260.0070.03019.20
5.4.250.0130.02719.28
5.4.240.0030.03318.87
5.4.230.0000.03719.04
5.4.220.0070.03719.04
5.4.210.0100.04719.13
5.4.200.0130.05318.87
5.4.190.0030.04319.20
5.4.180.0030.03319.15
5.4.170.0070.04318.84
5.4.160.0000.04019.13
5.4.150.0100.03719.10
5.4.140.0200.05316.36
5.4.130.0070.05716.35
5.4.120.0100.02716.38
5.4.110.0100.06316.36
5.4.100.0100.05316.36
5.4.90.0030.03316.43
5.4.80.0000.05716.49
5.4.70.0030.07316.38
5.4.60.0070.05716.33
5.4.50.0070.04716.39
5.4.40.0030.06716.48
5.4.30.0000.07316.36
5.4.20.0130.03016.32
5.4.10.0070.03716.47
5.4.00.0170.05715.65
5.3.290.0130.05014.80
5.3.280.0030.03714.64
5.3.270.0070.06314.69
5.3.260.0170.05714.68
5.3.250.0070.04014.63
5.3.240.0100.06014.63
5.3.230.0070.05314.55
5.3.220.0000.06314.62
5.3.210.0030.03714.64
5.3.200.0100.04314.70
5.3.190.0030.04014.68
5.3.180.0030.04014.65
5.3.170.0000.06714.54
5.3.160.0030.05714.69
5.3.150.0030.07014.57
5.3.140.0070.03714.59
5.3.130.0070.06014.68
5.3.120.0070.03314.56
5.3.110.0130.06014.52
5.3.100.0070.07714.16
5.3.90.0000.04014.15
5.3.80.0100.05313.96
5.3.70.0030.06314.09
5.3.60.0130.03314.07
5.3.50.0070.06713.97
5.3.40.0070.06714.02
5.3.30.0130.06713.81
5.3.20.0070.03313.64
5.3.10.0070.06713.74
5.3.00.0030.05713.68
5.2.170.0000.06011.29
5.2.160.0070.06011.29
5.2.150.0070.03011.29
5.2.140.0100.03311.29
5.2.130.0100.04711.29
5.2.120.0030.04311.29
5.2.110.0000.06711.29
5.2.100.0100.03011.29
5.2.90.0030.06311.29
5.2.80.0030.05011.29
5.2.70.0070.06011.29
5.2.60.0130.05711.29
5.2.50.0030.07011.29
5.2.40.0070.06011.29
5.2.30.0000.03011.29
5.2.20.0000.03711.29
5.2.10.0030.05011.29
5.2.00.0030.04711.29
5.1.60.0100.04311.29
5.1.50.0030.04711.29
5.1.40.0000.05311.29
5.1.30.0000.03311.29
5.1.20.0000.03011.29
5.1.10.0000.02311.29
5.1.00.0000.04011.29
5.0.50.0000.02311.29
5.0.40.0000.03311.29
5.0.30.0030.04711.29
5.0.20.0000.02011.29
5.0.10.0030.03011.29
5.0.00.0000.07011.29
4.4.90.0030.03711.29
4.4.80.0000.01311.29
4.4.70.0000.03711.29
4.4.60.0000.03011.29
4.4.50.0030.01311.29
4.4.40.0030.01711.29
4.4.30.0030.02011.29
4.4.20.0030.01711.29
4.4.10.0030.02311.29
4.4.00.0030.02311.29
4.3.110.0000.01311.29
4.3.100.0030.03311.29
4.3.90.0030.03311.29
4.3.80.0030.02711.29
4.3.70.0000.04711.29
4.3.60.0000.02011.29
4.3.50.0030.03311.29
4.3.40.0030.02711.29
4.3.30.0030.03011.29
4.3.20.0000.01711.29
4.3.10.0000.01711.29
4.3.00.0000.02011.29

preferences:
42.57 ms | 401 KiB | 5 Q