3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getWeeksInMonth($weekStartDay = 0) { $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.0130.01016.73
8.3.50.0040.01118.05
8.3.40.0070.01418.88
8.3.30.0100.00318.84
8.3.20.0050.00320.34
8.3.10.0030.00520.65
8.3.00.0040.00420.65
8.2.180.0040.01118.44
8.2.170.0110.00722.96
8.2.160.0090.00619.38
8.2.150.0030.00624.18
8.2.140.0040.00424.66
8.2.130.0000.00819.48
8.2.120.0040.00426.35
8.2.110.0030.00722.29
8.2.100.0090.00317.91
8.2.90.0090.00018.16
8.2.80.0040.00417.97
8.2.70.0040.00417.75
8.2.60.0000.00718.05
8.2.50.0080.00018.10
8.2.40.0070.00020.60
8.2.30.0000.00720.54
8.2.20.0000.00817.88
8.2.10.0050.00318.20
8.2.00.0040.00418.23
8.1.270.0000.00723.79
8.1.260.0060.00328.09
8.1.250.0040.00428.09
8.1.240.0060.00323.97
8.1.230.0090.00321.02
8.1.220.0060.00317.77
8.1.210.0040.00418.80
8.1.200.0040.00417.47
8.1.190.0050.00517.47
8.1.180.0040.00418.10
8.1.170.0050.00318.59
8.1.160.0070.00021.02
8.1.150.0000.00818.96
8.1.140.0030.00619.64
8.1.130.0040.00417.78
8.1.120.0040.00417.57
8.1.110.0070.00017.53
8.1.100.0000.00817.54
8.1.90.0040.00417.67
8.1.80.0000.00817.59
8.1.70.0030.00517.68
8.1.60.0030.00517.70
8.1.50.0050.00317.69
8.1.40.0080.00317.54
8.1.30.0080.00017.75
8.1.20.0040.00417.85
8.1.10.0000.00817.68
8.1.00.0060.00317.65
8.0.300.0040.00420.06
8.0.290.0040.00417.00
8.0.280.0040.00418.37
8.0.270.0000.00817.38
8.0.260.0080.00017.32
8.0.250.0070.00017.18
8.0.240.0030.00317.05
8.0.230.0040.00417.14
8.0.220.0040.00417.12
8.0.210.0040.00417.10
8.0.200.0000.00617.20
8.0.190.0040.00417.15
8.0.180.0000.00717.00
8.0.170.0070.00017.03
8.0.160.0040.00417.10
8.0.150.0080.00017.08
8.0.140.0040.00416.96
8.0.130.0030.00313.45
8.0.120.0040.00417.07
8.0.110.0000.00717.06
8.0.100.0040.00417.02
8.0.90.0030.00516.89
8.0.80.0180.00317.11
8.0.70.0070.00017.11
8.0.60.0040.00417.04
8.0.50.0040.00416.97
8.0.30.0100.00817.19
8.0.20.0050.01317.42
8.0.10.0000.00717.05
8.0.00.0110.01116.87
7.4.330.0030.00315.08
7.4.320.0030.00316.73
7.4.300.0000.00716.60
7.4.290.0040.00416.57
7.4.280.0060.00316.63
7.4.270.0040.00416.80
7.4.260.0000.00716.49
7.4.250.0080.00016.55
7.4.240.0050.00216.63
7.4.230.0000.00716.57
7.4.220.0120.00616.83
7.4.210.0170.00316.77
7.4.200.0070.00016.70
7.4.160.0030.01316.52
7.4.150.0030.01317.40
7.4.140.0170.00717.86
7.4.130.0080.01416.69
7.4.120.0080.01216.67
7.4.110.0070.01116.61
7.4.100.0100.01116.54
7.4.90.0120.00616.56
7.4.80.0160.01019.39
7.4.70.0070.01016.69
7.4.60.0090.01316.45
7.4.50.0040.01116.75
7.4.40.0060.01016.76
7.4.30.0160.00316.83
7.4.00.0070.00915.04
7.3.330.0050.00013.43
7.3.320.0030.00313.32
7.3.310.0020.00516.33
7.3.300.0000.00716.26
7.3.290.0060.01216.39
7.3.280.0080.01116.40
7.3.270.0060.01117.40
7.3.260.0100.00716.60
7.3.250.0100.00916.50
7.3.240.0090.00716.63
7.3.230.0060.01116.43
7.3.210.0060.01216.34
7.3.200.0120.00616.50
7.3.190.0090.00616.70
7.3.180.0030.01416.82
7.3.170.0100.01316.70
7.3.160.0060.01116.64
7.3.120.0100.00315.06
7.3.110.0030.01415.09
7.3.100.0080.00515.14
7.3.90.0000.01314.92
7.3.80.0060.00914.83
7.3.70.0040.00715.02
7.3.60.0040.01115.09
7.3.50.0070.00314.91
7.3.40.0030.00715.14
7.3.30.0000.01714.84
7.3.20.0110.00416.76
7.3.10.0090.00617.04
7.3.00.0040.00916.58
7.2.330.0110.00817.05
7.2.320.0120.00916.97
7.2.310.0120.00817.06
7.2.300.0120.00617.00
7.2.290.0100.00616.67
7.2.250.0140.00415.27
7.2.240.0100.01015.46
7.2.230.0040.01215.13
7.2.220.0060.00615.34
7.2.210.0030.01015.55
7.2.200.0060.00915.42
7.2.190.0030.01415.33
7.2.180.0070.01015.16
7.2.170.0030.00815.00
7.2.130.0000.01417.11
7.2.120.0050.00517.22
7.2.110.0090.00016.97
7.2.100.0060.00916.95
7.2.90.0070.00316.89
7.2.80.0000.01017.02
7.2.70.0090.00617.13
7.2.60.0070.00717.21
7.2.50.0090.00317.04
7.2.40.0090.00617.11
7.2.30.0090.00017.01
7.2.20.0040.01116.79
7.2.10.0070.00716.83
7.2.00.0050.00618.21
7.1.330.0040.01216.08
7.1.320.0030.00916.00
7.1.310.0030.01015.75
7.1.300.0030.00615.59
7.1.290.0070.00315.83
7.1.280.0070.00715.87
7.1.270.0060.00915.88
7.1.260.0100.00316.10
7.1.250.0100.00315.61
7.1.240.0130.00015.83
7.1.230.0040.00715.61
7.1.220.0070.00715.72
7.1.210.0070.00715.80
7.1.200.0060.00615.66
7.1.190.0100.00715.72
7.1.180.0060.00315.69
7.1.170.0100.00315.79
7.1.160.0000.00915.82
7.1.150.0110.00415.95
7.1.140.0070.01015.86
7.1.130.0100.00315.77
7.1.120.0120.00015.73
7.1.110.0030.00915.99
7.1.100.0040.00716.84
7.1.90.0100.00315.70
7.1.80.0030.01016.02
7.1.70.0090.00616.66
7.1.60.0120.00917.71
7.1.50.0060.00916.42
7.1.40.0060.01215.70
7.1.30.0040.01115.75
7.1.20.0040.01215.79
7.1.10.0030.01015.83
7.1.00.0050.04119.11
7.0.330.0000.01515.45
7.0.320.0080.00315.19
7.0.310.0070.00715.43
7.0.300.0070.00415.58
7.0.290.0030.01015.45
7.0.280.0030.00815.46
7.0.270.0090.00615.13
7.0.260.0100.00315.41
7.0.250.0070.00415.43
7.0.240.0040.00715.59
7.0.230.0070.00715.64
7.0.220.0000.01015.62
7.0.210.0030.00615.64
7.0.200.0020.01116.27
7.0.190.0110.00315.67
7.0.180.0090.00615.30
7.0.170.0000.01515.30
7.0.160.0050.00315.61
7.0.150.0070.00715.74
7.0.140.0000.01215.49
7.0.130.0070.00715.35
7.0.120.0060.00615.58
7.0.110.0100.00715.61
7.0.100.0100.00315.68
7.0.90.0130.00015.47
7.0.80.0080.00415.52
7.0.70.0040.01115.72
7.0.60.0150.03317.71
7.0.50.0050.04716.66
7.0.40.0120.03716.84
7.0.30.0170.03316.80
7.0.20.0100.03716.85
7.0.10.0130.03217.09
7.0.00.0030.04116.96
5.6.380.0030.00614.50
5.6.370.0000.01214.70
5.6.360.0060.00614.71
5.6.350.0060.01214.46
5.6.340.0040.00714.42
5.6.330.0060.00614.55
5.6.320.0070.00714.28
5.6.310.0000.01614.63
5.6.300.0090.00414.65
5.6.290.0060.00614.57
5.6.280.0050.04017.69
5.6.270.0070.00414.27
5.6.260.0040.00714.64
5.6.250.0040.00414.20
5.6.240.0040.00714.40
5.6.230.0050.00514.57
5.6.220.0090.00314.53
5.6.210.0050.02917.59
5.6.200.0030.04716.38
5.6.190.0110.03417.34
5.6.180.0080.03617.59
5.6.170.0130.03017.40
5.6.160.0130.03017.60
5.6.150.0100.03017.42
5.6.140.0130.03717.61
5.6.130.0100.03117.28
5.6.120.0070.03617.49
5.6.110.0160.03717.65
5.6.100.0080.03117.49
5.6.90.0200.02717.50
5.6.80.0120.03417.07
5.6.70.0050.03516.80
5.6.60.0120.03016.93
5.6.50.0170.02517.04
5.6.40.0120.03616.97
5.6.30.0080.03617.13
5.6.20.0160.02517.16
5.6.10.0130.03016.98
5.6.00.0120.03716.95
5.5.380.0080.00311.52
5.5.370.0000.01011.49
5.5.360.0030.00511.39
5.5.350.0020.03915.88
5.5.340.0070.02514.57
5.5.330.0120.03415.72
5.5.320.0150.02715.96
5.5.310.0100.03115.94
5.5.300.0220.03515.68
5.5.290.0080.03315.78
5.5.280.0100.03215.82
5.5.270.0120.03115.83
5.5.260.0080.03015.87
5.5.250.0080.03315.67
5.5.240.0100.03215.39
5.5.230.0100.03215.53
5.5.220.0100.03615.50
5.5.210.0120.03015.37
5.5.200.0090.03015.39
5.5.190.0150.02515.29
5.5.180.0140.02915.41
5.5.170.0040.00411.22
5.5.160.0130.03415.59
5.5.150.0180.04115.47
5.5.140.0080.03615.48
5.5.130.0120.02815.39
5.5.120.0130.03015.37
5.5.110.0070.03515.42
5.5.100.0070.03215.41
5.5.90.0050.03715.21
5.5.80.0130.03815.26
5.5.70.0120.03215.35
5.5.60.0130.04015.47
5.5.50.0130.02515.47
5.5.40.0050.03515.43
5.5.30.0100.02915.43
5.5.20.0100.03015.38
5.5.10.0120.03215.26
5.5.00.0080.03215.33

preferences:
77.12 ms | 400 KiB | 5 Q