3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getWeeksInMonth($weekStartDay = 1) { $date = new \Datetime('2015-03-01'); // Total number of days in the given month.; $numberOfDays = $date->format("t"); // Count the number of times it hits $weekStartDay. $numberOfWeeks = 1; for ($i = 1; $i <= $numberOfDays; $i++) { $nextDay = $date->add(new \DateInterval('P1D')); $dayOfWeek = $nextDay->format('w'); if ($dayOfWeek == $weekStartDay) { $numberOfWeeks++; } } return $numberOfWeeks; } echo getWeeksInMonth();

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.0120.00916.75
8.3.50.0230.00821.99
8.3.40.0070.00718.83
8.3.30.0110.00418.48
8.3.20.0040.00420.16
8.3.10.0040.00420.65
8.3.00.0080.00020.67
8.2.180.0040.01116.63
8.2.170.0170.00322.96
8.2.160.0070.00719.34
8.2.150.0040.00424.18
8.2.140.0000.00824.66
8.2.130.0040.00426.16
8.2.120.0040.00418.79
8.2.110.0100.00022.15
8.2.100.0110.00017.85
8.2.90.0040.00418.28
8.2.80.0060.00317.97
8.2.70.0040.00417.88
8.2.60.0030.00517.93
8.2.50.0000.00818.10
8.2.40.0000.00820.55
8.2.30.0070.00020.55
8.2.20.0040.00417.79
8.2.10.0040.00418.07
8.2.00.0050.00218.13
8.1.280.0070.01025.92
8.1.270.0000.00823.96
8.1.260.0040.00426.35
8.1.250.0050.00328.09
8.1.240.0060.00323.92
8.1.230.0080.00321.04
8.1.220.0030.00617.77
8.1.210.0040.00418.77
8.1.200.0060.00317.48
8.1.190.0030.00517.48
8.1.180.0040.00418.10
8.1.170.0000.00818.74
8.1.160.0030.00320.92
8.1.150.0070.00019.03
8.1.140.0000.00819.58
8.1.130.0030.00317.62
8.1.120.0050.00517.64
8.1.110.0030.00617.61
8.1.100.0040.00417.64
8.1.90.0040.00417.64
8.1.80.0040.00417.64
8.1.70.0030.00317.54
8.1.60.0050.00317.68
8.1.50.0030.00517.64
8.1.40.0030.00917.54
8.1.30.0000.00917.71
8.1.20.0000.00917.86
8.1.10.0040.00417.59
8.1.00.0050.00317.59
8.0.300.0040.00420.16
8.0.290.0030.00616.88
8.0.280.0040.00418.48
8.0.270.0070.00017.38
8.0.260.0030.00317.38
8.0.250.0080.00017.19
8.0.240.0030.00317.19
8.0.230.0000.00817.04
8.0.220.0050.00216.98
8.0.210.0000.00717.07
8.0.200.0040.00417.13
8.0.190.0030.00517.19
8.0.180.0040.00417.00
8.0.170.0000.00817.11
8.0.160.0040.00417.14
8.0.150.0040.00417.03
8.0.140.0000.00817.07
8.0.130.0060.00013.48
8.0.120.0060.00316.96
8.0.110.0080.00017.08
8.0.100.0000.00717.05
8.0.90.0050.00216.98
8.0.80.0120.00917.04
8.0.70.0040.00417.13
8.0.60.0070.00017.16
8.0.50.0050.00317.11
8.0.30.0110.00917.25
8.0.20.0130.00717.44
8.0.10.0040.00417.21
8.0.00.0110.00916.92
7.4.330.0060.00015.08
7.4.320.0030.00316.61
7.4.300.0060.00016.55
7.4.290.0030.00316.62
7.4.280.0040.00416.71
7.4.270.0000.00816.74
7.4.260.0030.00316.67
7.4.250.0070.00016.75
7.4.240.0030.00316.64
7.4.230.0070.00016.68
7.4.220.0110.00716.59
7.4.210.0050.01016.63
7.4.200.0060.00316.74
7.4.160.0130.00316.57
7.4.150.0060.01417.40
7.4.140.0110.01017.86
7.4.130.0090.00916.53
7.4.120.0100.00816.76
7.4.110.0120.00616.55
7.4.100.0100.01016.59
7.4.90.0110.00716.70
7.4.80.0140.01119.39
7.4.70.0090.00916.83
7.4.60.0030.01716.76
7.4.50.0070.00716.79
7.4.40.0060.00916.75
7.4.30.0110.01116.81
7.4.00.0030.01315.14
7.3.330.0020.00213.46
7.3.320.0030.00213.48
7.3.310.0030.00316.33
7.3.300.0030.00616.44
7.3.290.0030.00316.31
7.3.280.0090.00716.44
7.3.270.0070.01117.40
7.3.260.0030.01616.66
7.3.250.0100.01016.60
7.3.240.0110.00816.67
7.3.230.0070.01316.74
7.3.210.0060.01016.69
7.3.200.0100.00716.64
7.3.190.0090.00616.50
7.3.180.0060.01016.64
7.3.170.0110.00616.57
7.3.160.0100.00716.74
7.2.330.0030.01416.99
7.2.320.0120.00616.88
7.2.310.0120.01016.81
7.2.300.0090.01516.91
7.2.290.0030.01316.61
7.2.00.0000.01219.71
7.1.200.0040.00415.99
7.1.100.0000.01018.19
7.1.70.0040.00417.39
7.1.60.0060.01319.48
7.1.00.0000.07322.40
7.0.200.0030.00516.72
7.0.60.0330.06320.04
7.0.50.0170.05717.87
7.0.40.0300.05720.43
7.0.30.0230.06020.21
7.0.20.0370.06720.12
7.0.10.0230.07020.43
7.0.00.0300.05720.02
5.6.280.0000.07720.87
5.6.210.0100.08020.51
5.6.200.0070.08018.22
5.6.190.0330.06320.66
5.6.180.0200.05720.62
5.6.170.0200.06020.41
5.6.160.0200.06020.54
5.6.150.0170.06020.47
5.6.140.0200.05720.57
5.6.130.0170.06020.16
5.6.120.0130.07020.46
5.6.110.0370.05320.43
5.6.100.0070.06320.37
5.6.90.0500.05720.17
5.6.80.0330.06319.79
5.6.70.0400.06019.96
5.6.60.0230.06719.70
5.6.50.0430.05719.79
5.6.40.0300.06319.75
5.6.30.0130.05719.53
5.6.20.0070.06319.74
5.6.10.0230.05019.59
5.6.00.0330.03719.65
5.5.350.0070.07720.33
5.5.340.0000.04717.98
5.5.330.0230.06720.19
5.5.320.0230.06020.19
5.5.310.0100.07020.43
5.5.300.0100.07020.18
5.5.290.0270.05720.36
5.5.280.0100.06019.97
5.5.270.0200.08320.38
5.5.260.0430.05320.34
5.5.250.0500.05319.91
5.5.240.0400.05319.36
5.5.230.0570.07019.48
5.5.220.0470.08719.48
5.5.210.0170.07319.76
5.5.200.0600.05019.63
5.5.190.0270.05319.39
5.5.180.0230.06319.66
5.5.160.0200.05019.65
5.5.150.0170.06019.67
5.5.140.0270.05019.33
5.5.130.0230.04019.53
5.5.120.0430.05319.45
5.5.110.0430.05319.38
5.5.100.0430.05319.24
5.5.90.0430.06019.54
5.5.80.0070.05719.51
5.5.70.0070.06019.54
5.5.60.0270.06319.62
5.5.50.0400.05319.60
5.5.40.0330.06019.35
5.5.30.0370.04719.38
5.5.20.0070.05719.57
5.5.10.0100.06719.44
5.5.00.0500.05019.37

preferences:
60.31 ms | 401 KiB | 5 Q