3v4l.org

run code in 300+ PHP versions simultaneously
<?php $start_date = '2019-01-01'; $end_date = '2019-12-31'; function makeBroadcastCalendar($start_date, $end_date) { $end = new DateTime($end_date); $start = new DateTime($start_date); $start->modify('monday this week'); $week = 1; $weeks = array(); while($start < $end) { $weeks[$week++] = $start->format('Y-m-d'); $start->modify('+1 week'); } return $weeks; } function getBroadcastMonth($date) { $end_of_week = new DateTime($date); $end_of_week->modify('sunday this week'); return (int)$end_of_week->format('n'); } function getBroadcastWeek($date) { $start = new DateTime($date); $start->modify('January 1'); $start->modify('monday this week'); $start_of_week = new DateTime($date); $start_of_week->modify('monday this week'); $week = 1; while ($start < $start_of_week) { $start->modify('+1 week'); $week++; } return $week; } function getFirstAndLast($year, $month) { $start = new DateTime("$year-$month-01"); $end = clone $start; $start->modify('monday this week'); $output = array('first_day' => $start->format('Y-m-d')); $end->modify('+1 month'); $end->modify('monday this week'); while ($start < $end) { $start->modify('+1 week'); } $output['end'] = $start->modify('-1 day')->format('Y-m-d'); return $output; } echo getBroadcastMonth('2019-10-12') . PHP_EOL; echo getBroadcastMonth('2019-10-29') . PHP_EOL; echo getBroadcastMonth('2019-05-31') . PHP_EOL; echo getBroadcastWeek('2019-10-12') . PHP_EOL; echo getBroadcastWeek('2019-10-29') . PHP_EOL; echo getBroadcastWeek('2019-05-31') . PHP_EOL; for ($i = 1; $i <= 12; $i++) { print_r(getFirstAndLast(2019, $i)); }

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.4.120.0110.01022.01
8.4.110.0110.00719.98
8.4.100.0120.00817.66
8.4.90.0140.00722.25
8.4.80.0150.00519.04
8.4.70.0100.01020.71
8.4.60.0100.01120.40
8.4.50.0130.00819.69
8.4.40.0120.00919.65
8.4.30.0210.00020.55
8.4.20.0030.01322.29
8.4.10.0060.00319.76
8.3.250.0060.00316.97
8.3.240.0100.01216.92
8.3.230.0110.01016.73
8.3.220.0100.01019.16
8.3.210.0050.00316.87
8.3.200.0060.00316.86
8.3.190.0100.01116.84
8.3.180.0050.01618.88
8.3.170.0140.00717.43
8.3.160.0130.00616.69
8.3.150.0000.01218.90
8.3.140.0100.01016.84
8.3.130.0080.00416.83
8.3.120.0060.00320.86
8.3.110.0060.00320.94
8.3.100.0060.00318.46
8.3.90.0060.00326.77
8.3.80.0000.01017.97
8.3.70.0130.00317.00
8.3.60.0090.00618.60
8.3.50.0030.01018.61
8.3.40.0160.00018.76
8.3.30.0070.01018.79
8.3.20.0040.00421.72
8.3.10.0090.00021.73
8.3.00.0050.00322.39
8.2.290.0050.00516.70
8.2.280.0110.00918.47
8.2.270.0050.00516.84
8.2.260.0040.00420.61
8.2.250.0080.00018.66
8.2.240.0030.00617.22
8.2.230.0040.00422.58
8.2.220.0070.01124.06
8.2.210.0060.00326.77
8.2.200.0070.00318.66
8.2.190.0150.00616.88
8.2.180.0190.00718.41
8.2.170.0110.01122.96
8.2.160.0110.00420.36
8.2.150.0030.00524.18
8.2.140.0040.00424.66
8.2.130.0060.00326.16
8.2.120.0050.00319.61
8.2.110.0040.00420.89
8.2.100.0090.00318.09
8.2.90.0030.00518.45
8.2.80.0040.00418.34
8.2.70.0060.00317.88
8.2.60.0060.00317.88
8.2.50.0080.00018.10
8.2.40.0030.00519.66
8.2.30.0000.00819.34
8.2.20.0030.00518.28
8.2.10.0000.00819.24
8.2.00.0040.00419.33
8.1.330.0140.00516.72
8.1.320.0130.00916.17
8.1.310.0070.00316.68
8.1.300.0060.00317.90
8.1.290.0030.00630.84
8.1.280.0030.01225.92
8.1.270.0040.00722.64
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0030.00622.73
8.1.230.0060.00622.74
8.1.220.0040.00417.91
8.1.210.0060.00318.77
8.1.200.0030.00617.60
8.1.190.0040.00417.60
8.1.180.0040.00418.10
8.1.170.0030.00618.83
8.1.160.0040.00419.04
8.1.150.0040.00419.05
8.1.140.0000.00819.05
8.1.130.0040.00417.64
8.1.120.0000.00917.75
8.1.110.0060.00317.75
8.1.100.0000.00917.72
8.1.90.0040.00417.66
8.1.80.0000.00817.71
8.1.70.0000.00817.73
8.1.60.0030.00517.70
8.1.50.0060.00617.78
8.1.40.0000.00817.62
8.1.30.0080.00017.70
8.1.20.0030.00517.79
8.1.10.0030.00617.78
8.1.00.0000.00917.79
8.0.300.0040.00420.08
8.0.290.0040.00417.00
8.0.280.0040.00418.51
8.0.270.0040.00417.10
8.0.260.0030.00517.04
8.0.250.0040.00417.18
8.0.240.0030.00517.13
8.0.230.0040.00417.25
8.0.220.0000.00917.11
8.0.210.0000.00717.06
8.0.200.0040.00417.25
8.0.190.0080.00017.13
8.0.180.0030.00517.13
8.0.170.0080.00417.13
8.0.160.0060.00317.25
8.0.150.0060.00317.22
8.0.140.0000.00817.04
8.0.130.0030.00613.54
8.0.120.0000.01017.19
8.0.110.0040.00417.01
8.0.100.0030.00617.16
8.0.90.0000.00817.04
8.0.80.0080.01117.06
8.0.70.0040.00417.07
8.0.60.0050.00317.00
8.0.50.0030.00517.11
8.0.30.0100.00917.21
8.0.20.0110.00817.35
8.0.10.0050.00317.21
8.0.00.0140.00617.03
7.4.330.0000.00615.55
7.4.320.0060.00016.71
7.4.300.0030.00316.78
7.4.290.0000.00816.75
7.4.280.0050.00316.67
7.4.270.0040.00416.73
7.4.260.0000.00713.45
7.4.250.0040.00416.72
7.4.240.0080.00016.62
7.4.230.0080.00016.79
7.4.220.0080.00016.61
7.4.210.0060.01116.80
7.4.200.0040.00416.71
7.4.130.0100.01016.61
7.4.120.0030.02316.77
7.4.110.0000.02116.71
7.4.100.0140.00316.79
7.4.90.0090.00916.55
7.4.80.0070.01019.39
7.4.70.0060.01516.99
7.4.60.0060.01216.84
7.4.50.0140.00016.56
7.4.40.0080.01116.77
7.4.00.0040.01115.23
7.3.330.0050.00316.58
7.3.320.0000.00613.57
7.3.310.0040.00416.60
7.3.300.0000.00716.53
7.3.290.0040.00416.50
7.3.260.0120.00816.63
7.3.230.0070.01016.70
7.3.210.0110.00616.64
7.3.200.0030.01516.73
7.3.190.0030.01416.63
7.3.180.0040.01316.72
7.3.170.0070.01716.57
7.3.160.0070.01116.56
7.3.110.0030.01214.91
7.3.100.0110.00515.20
7.3.90.0140.00314.75
7.3.80.0030.01314.99
7.3.70.0100.01014.85
7.3.60.0060.01514.77
7.3.50.0060.00914.93
7.3.40.0030.01615.05
7.3.30.0110.00815.00
7.3.20.0090.01514.80
7.3.10.0070.01415.07
7.3.00.0070.00714.97
7.2.330.0150.00917.16
7.2.320.0080.01116.80
7.2.310.0100.00716.90
7.2.300.0060.01216.95
7.2.290.0090.00917.08
7.2.240.0110.00715.04
7.2.230.0080.00815.22
7.2.220.0070.00715.17
7.2.210.0050.01115.40
7.2.200.0040.01415.32
7.2.190.0130.00914.96
7.2.180.0140.00015.03
7.2.170.0070.01415.06
7.2.160.0160.00915.14
7.2.150.0120.01215.32
7.2.140.0070.01415.06
7.2.130.0080.01315.43
7.2.120.0100.00715.40
7.2.110.0030.01215.38
7.2.100.0130.00415.22
7.2.90.0000.01615.31
7.2.80.0110.00515.34
7.2.70.0150.00915.18
7.2.60.0100.01315.13
7.2.50.0100.00615.39
7.2.40.0090.00915.44
7.2.30.0080.00815.40
7.2.20.0070.01015.37
7.2.10.0030.01415.19
7.2.00.0070.01015.44
7.1.330.0040.01514.04
7.1.320.0030.01013.94
7.1.310.0580.01014.25
7.1.300.0160.00614.37
7.1.290.0030.01314.25
7.1.280.0100.01014.17
7.1.270.0000.01413.92
7.1.260.0160.00613.87
7.1.250.0150.00014.11

preferences:
14.33 ms | 403 KiB | 5 Q