3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Settings $workStartHour = 9; $workStartMin = 0; $workEndHour = 17; $workEndMin = 30; $workdayHours = 8.5; $weekends = array('Saturday', 'Sunday'); $hours = 0; // Original start and end times, and their clones that we'll modify. $originalStart = new DateTime('2014-06-25 11:30:00'); $start = clone $originalStart; // Starting on a weekend? Skip to a weekday. while (in_array($start->format('l'), $weekends)) { $start->modify('midnight tomorrow'); } $originalEnd = new DateTime('2014-07-22 12:30:00'); $end = clone $originalEnd; // Ending on a weekend? Go back to a weekday. while (in_array($end->format('l'), $weekends)) { $end->modify('-1 day')->setTime(23, 59); } // Is the start date after the end date? Might happen if start and end // are on the same weekend (whoops). if ($start > $end) throw new Exception('Start date is AFTER end date!'); // Are the times outside of normal work hours? If so, adjust. $startAdj = clone $start; if ($start < $startAdj->setTime($workStartHour, $workStartMin)) { // Start is earlier; adjust to real start time. $start = $startAdj; } else if ($start > $startAdj->setTime($workEndHour, $workEndMin)) { // Start is after close of that day, move to tomorrow. $start = $startAdj->setTime($workStartHour, $workStartMin)->modify('+1 day'); } $endAdj = clone $end; if ($end > $endAdj->setTime($workEndHour, $workEndMin)) { // End is after; adjust to real end time. $end = $endAdj; } else if ($end < $endAdj->setTime($workStartHour, $workStartMin)) { // End is before start of that day, move to day before. $end = $endAdj->setTime($workEndHour, $workEndMin)->modify('-1 day'); } // Calculate the difference between our modified days. $diff = $start->diff($end); // Go through each day using the original values, so we can check for weekends. $period = new DatePeriod($start, new DateInterval('P1D'), $end); foreach ($period as $day) { // If it's a weekend day, take it out of our total days in the diff. if (in_array($day->format('l'), array('Saturday', 'Sunday'))) $diff->d--; } // Calculate! Days * Hours in a day + hours + minutes converted to hours. $hours = ($diff->d * $workdayHours) + $diff->h + round($diff->i / 60, 2);

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.0040.01216.74
8.3.50.0070.00922.04
8.3.40.0120.00318.95
8.3.30.0070.00719.16
8.3.20.0040.00420.28
8.3.10.0050.00323.48
8.3.00.0040.00418.99
8.2.180.0040.01118.27
8.2.170.0070.00722.96
8.2.160.0070.00720.47
8.2.150.0080.00024.18
8.2.140.0050.00324.66
8.2.130.0080.00026.16
8.2.120.0080.00020.73
8.2.110.0060.00322.13
8.2.100.0070.00418.03
8.2.90.0060.00319.38
8.2.80.0060.00317.97
8.2.70.0060.00317.75
8.2.60.0050.00518.04
8.2.50.0030.00518.07
8.2.40.0050.00321.19
8.2.30.0000.00820.10
8.2.20.0080.00017.84
8.2.10.0020.00518.22
8.2.00.0000.00817.86
8.1.280.0110.00425.92
8.1.270.0040.00423.83
8.1.260.0050.00326.35
8.1.250.0070.00028.09
8.1.240.0060.00323.84
8.1.230.0060.00619.08
8.1.220.0050.00317.78
8.1.210.0000.00818.77
8.1.200.0040.00717.60
8.1.190.0080.00017.35
8.1.180.0040.00418.10
8.1.170.0030.00518.62
8.1.160.0000.00722.07
8.1.150.0040.00418.77
8.1.140.0040.00417.67
8.1.130.0030.00317.84
8.1.120.0030.00517.67
8.1.110.0080.00017.73
8.1.100.0000.00817.64
8.1.90.0040.00417.69
8.1.80.0000.00717.69
8.1.70.0070.00017.53
8.1.60.0040.00417.73
8.1.50.0040.00417.67
8.1.40.0040.00817.55
8.1.30.0000.00817.79
8.1.20.0000.00817.81
8.1.10.0040.00417.74
8.1.00.0080.00017.69
8.0.300.0000.00718.77
8.0.290.0040.00417.05
8.0.280.0000.00718.45
8.0.270.0000.00717.36
8.0.260.0030.00317.27
8.0.250.0030.00317.25
8.0.240.0030.00317.07
8.0.230.0050.00317.07
8.0.220.0070.00017.07
8.0.210.0030.00317.13
8.0.200.0000.00817.07
8.0.190.0000.00717.18
8.0.180.0050.00217.20
8.0.170.0000.00717.19
8.0.160.0000.00717.12
8.0.150.0040.00417.08
8.0.140.0000.00717.08
8.0.130.0000.00613.43
8.0.120.0080.00017.03
8.0.110.0080.00017.09
8.0.100.0050.00317.12
8.0.90.0000.00716.93
8.0.80.0090.00617.07
8.0.70.0000.00817.17
8.0.60.0020.00516.95
8.0.50.0070.00017.15
8.0.30.0110.00817.36
8.0.20.0100.01417.40
8.0.10.0000.00717.10
8.0.00.0130.00517.00
7.4.330.0000.00515.20
7.4.320.0030.00316.72
7.4.300.0040.00416.68
7.4.290.0070.00016.75
7.4.280.0050.00316.72
7.4.270.0070.00016.78
7.4.260.0030.00516.55
7.4.250.0030.00516.73
7.4.240.0040.00416.67
7.4.230.0000.00716.56
7.4.220.0060.01616.79
7.4.210.0050.01116.63
7.4.200.0000.00816.47
7.4.190.0000.00716.65
7.4.160.0160.00316.68
7.4.150.0130.00617.40
7.4.140.0180.01617.86
7.4.130.0110.00816.78
7.4.120.0090.00816.82
7.4.110.0130.00616.77
7.4.100.0150.01116.63
7.4.90.0120.00716.47
7.4.80.0090.01419.39
7.4.70.0070.01016.84
7.4.60.0150.00716.75
7.4.50.0030.00616.50
7.4.40.0090.01316.83
7.4.30.0170.00616.74
7.4.10.0070.01314.96
7.4.00.0040.01215.22
7.3.330.0000.00613.41
7.3.320.0050.00013.14
7.3.310.0000.00716.37
7.3.300.0030.00316.46
7.3.290.0080.00816.46
7.3.280.0060.01216.45
7.3.270.0120.01317.40
7.3.260.0150.00616.71
7.3.250.0110.00816.70
7.3.240.0060.01316.95
7.3.230.0030.01416.39
7.3.210.0100.01316.59
7.3.200.0160.00619.39
7.3.190.0080.01416.57
7.3.180.0070.01016.61
7.3.170.0110.00616.73
7.3.160.0100.00716.43
7.3.130.0060.01215.08
7.3.120.0080.01015.00
7.3.110.0060.01314.91
7.3.100.0090.00315.01
7.3.90.0060.01014.91
7.3.80.0000.00915.26
7.3.70.0070.00714.88
7.3.60.0070.01015.20
7.3.50.0120.00315.16
7.3.40.0040.00714.89
7.3.30.0030.01314.96
7.3.20.0000.00816.87
7.3.10.0100.00316.48
7.3.00.0040.01116.92
7.2.330.0040.01316.63
7.2.320.0150.00316.99
7.2.310.0030.01416.75
7.2.300.0030.01316.68
7.2.290.0070.01016.61
7.2.260.0070.01415.26
7.2.250.0140.00415.56
7.2.240.0110.00415.46
7.2.230.0040.01115.53
7.2.220.0000.01515.48
7.2.210.0000.01115.48
7.2.200.0080.00815.32
7.2.190.0080.00615.31
7.2.180.0100.00715.38
7.2.170.0030.00915.26
7.2.160.0100.00715.36
7.2.150.0030.00916.98
7.2.140.0120.00616.91
7.2.130.0000.01116.91
7.2.120.0060.00617.12
7.2.110.0120.00417.12
7.2.100.0070.01017.25
7.2.90.0050.00516.95
7.2.80.0000.01516.80
7.2.70.0070.00717.18
7.2.60.0070.01016.88
7.2.50.0080.01117.25
7.2.40.0060.00616.82
7.2.30.0070.00417.11
7.2.20.0060.00617.16
7.2.10.0070.00717.21
7.2.00.0040.01418.31
7.1.330.0070.00716.06
7.1.320.0100.00316.02
7.1.310.0100.00315.84
7.1.300.0100.00315.71
7.1.290.0060.00816.04
7.1.280.0080.00316.04
7.1.270.0080.00315.93
7.1.260.0100.00716.03
7.1.250.0060.00815.95
7.1.240.0080.00816.03
7.1.230.0080.00816.08
7.1.220.0040.00715.94
7.1.210.0040.00416.17
7.1.200.0040.01115.81
7.1.190.0040.01416.13
7.1.180.0040.00815.88
7.1.170.0000.01515.95
7.1.160.0100.00316.08
7.1.150.0030.00915.98
7.1.140.0040.01115.99
7.1.130.0030.00615.80
7.1.120.0030.00716.04
7.1.110.0100.00016.10
7.1.100.0080.00717.13
7.1.90.0090.00615.80
7.1.80.0030.00916.12
7.1.70.0040.00716.63
7.1.60.0090.01117.77
7.1.50.0090.00716.58
7.1.40.0060.01215.84
7.1.30.0090.00316.10
7.1.20.0030.00915.75
7.1.10.0030.01315.94
7.1.00.0020.04419.16
7.0.330.0080.00515.46
7.0.320.0100.00315.61
7.0.310.0070.00715.70
7.0.300.0050.00515.70
7.0.290.0040.01315.52
7.0.280.0030.01015.64
7.0.270.0000.01115.56
7.0.260.0090.00615.70
7.0.250.0040.01215.71
7.0.240.0160.00015.66
7.0.230.0100.00315.71
7.0.220.0110.00415.69
7.0.210.0090.00915.82
7.0.200.0080.01016.36
7.0.190.0040.01115.65
7.0.180.0060.00615.39
7.0.170.0040.01015.67
7.0.160.0030.01215.66
7.0.150.0100.00715.38
7.0.140.0100.03718.66
7.0.130.0050.00515.71
7.0.120.0060.00915.72
7.0.110.0030.01415.66
7.0.100.0230.01717.87
7.0.90.0100.02617.87
7.0.80.0130.04417.87
7.0.70.0070.02517.63
7.0.60.0050.02817.69
7.0.50.0090.04418.10
7.0.40.0090.02816.86
7.0.30.0080.03816.98
7.0.20.0060.03116.85
7.0.10.0110.02516.84
7.0.00.0070.03016.79
5.6.400.0120.00314.45
5.6.390.0050.00514.63
5.6.380.0000.01514.71
5.6.370.0030.00614.72
5.6.360.0030.00714.61
5.6.350.0070.01014.46
5.6.340.0030.01414.45
5.6.330.0070.00714.72
5.6.320.0100.00714.73
5.6.310.0080.01214.72
5.6.300.0060.00614.58
5.6.290.0100.00314.91
5.6.280.0020.04317.83
5.6.270.0070.01114.73
5.6.260.0150.00014.22
5.6.250.0070.04017.68
5.6.240.0060.02817.51
5.6.230.0100.04317.52
5.6.220.0030.05217.46
5.6.210.0030.05017.43
5.6.200.0060.04317.75
5.6.190.0090.04417.71
5.6.180.0100.03317.73
5.6.170.0130.04017.66
5.6.160.0030.03517.74
5.6.150.0100.03317.85
5.6.140.0120.03317.73
5.6.130.0100.03817.79
5.6.120.0050.02517.75
5.6.110.0060.04117.99
5.6.100.0050.04517.70
5.6.90.0060.03917.72
5.6.80.0120.02717.43
5.6.70.0080.02717.39
5.6.60.0060.02917.57
5.6.50.0030.02817.25
5.6.40.0090.02317.53
5.6.30.0080.02017.40
5.6.20.0060.02717.36
5.6.10.0070.02817.51
5.6.00.0030.03517.34
5.5.380.0020.02817.35
5.5.370.0090.04417.48
5.5.360.0080.04417.44
5.5.350.0070.04717.50
5.5.340.0080.04217.51
5.5.330.0030.03817.48
5.5.320.0060.02517.53
5.5.310.0060.02817.62
5.5.300.0130.03517.69
5.5.290.0060.02617.49
5.5.280.0050.02817.71
5.5.270.0060.02717.59
5.5.260.0080.03417.67
5.5.250.0090.04017.47
5.5.240.0070.03417.34
5.5.230.0150.02817.33
5.5.220.0060.04117.25
5.5.210.0070.02717.26
5.5.200.0030.03417.21
5.5.190.0090.02617.28
5.5.180.0080.03117.33
5.5.170.0090.00614.46
5.5.160.0080.03317.33
5.5.150.0080.04017.20
5.5.140.0090.02517.18
5.5.130.0100.02517.18
5.5.120.0080.02217.29
5.5.110.0150.03517.19
5.5.100.0050.04317.34
5.5.90.0070.04017.43
5.5.80.0060.02417.29
5.5.70.0100.02217.18
5.5.60.0100.02217.05
5.5.50.0110.02717.03
5.5.40.0070.02717.03
5.5.30.0090.03817.17
5.5.20.0070.04117.20
5.5.10.0050.02817.19
5.5.00.0080.02617.02
5.4.450.0050.02616.46
5.4.440.0030.04016.47
5.4.430.0040.02716.45
5.4.420.0080.02616.52
5.4.410.0030.02816.44
5.4.400.0050.03916.39
5.4.390.0070.04016.39
5.4.380.0060.02316.43
5.4.370.0100.01816.27
5.4.360.0080.02516.43
5.4.350.0060.03016.43
5.4.340.0070.03216.38
5.4.330.0040.00713.63
5.4.320.0110.02816.34
5.4.310.0080.04116.35
5.4.300.0030.03316.22
5.4.290.0040.02316.37
5.4.280.0050.03716.40
5.4.270.0060.03516.34
5.4.260.0050.02716.21
5.4.250.0090.02116.33
5.4.240.0130.01816.43
5.4.230.0030.04516.37
5.4.220.0020.04516.30
5.4.210.0050.04516.21
5.4.200.0060.02316.29
5.4.190.0040.02516.22
5.4.180.0050.04216.32
5.4.170.0050.02716.37
5.4.160.0040.02216.32
5.4.150.0060.02216.32
5.4.140.0100.02214.98
5.4.130.0020.02214.95
5.4.120.0050.02614.98
5.4.110.0050.03614.97
5.4.100.0040.02515.00
5.4.90.0110.03515.06
5.4.80.0030.02315.07
5.4.70.0080.03615.03
5.4.60.0080.03914.94
5.4.50.0110.03015.03
5.4.40.0110.03314.98
5.4.30.0100.03714.96
5.4.20.0070.03614.94
5.4.10.0050.03914.96
5.4.00.0070.02314.66
5.3.290.0130.05714.64
5.3.280.0070.06314.61
5.3.270.0100.07014.58
5.3.260.0030.08014.61
5.3.250.0030.04314.63
5.3.240.0070.03314.61
5.3.230.0000.06714.48
5.3.220.0070.03314.45
5.3.210.0100.04014.59
5.3.200.0070.06714.41
5.3.190.0130.07314.45
5.3.180.0070.06314.57
5.3.170.0100.07014.60
5.3.160.0070.07714.57
5.3.150.0070.07314.58
5.3.140.0030.04014.40
5.3.130.0030.04714.39
5.3.120.0200.06714.53
5.3.110.0000.07314.53
5.3.100.0000.07014.03
5.3.90.0130.06713.97
5.3.80.0030.07313.90
5.3.70.0070.06313.79
5.3.60.0070.05314.00
5.3.50.0070.04013.95
5.3.40.0130.07313.73
5.3.30.0070.06013.90
5.3.20.0000.04013.70
5.3.10.0070.07013.44
5.3.00.0070.07013.64
5.2.170.0070.04713.15
5.2.160.0030.06013.15
5.2.150.0070.05013.15
5.2.140.0070.04013.15
5.2.130.0100.05713.15
5.2.120.0070.05713.15
5.2.110.0000.06713.15
5.2.100.0030.06313.15
5.2.90.0070.05313.15
5.2.80.0000.05313.15
5.2.70.0030.03713.15
5.2.60.0070.04713.15
5.2.50.0130.05013.15
5.2.40.0030.03713.15
5.2.30.0030.04013.15
5.2.20.0000.06713.15
5.2.10.0030.03313.15
5.2.00.0100.02313.15
5.1.60.0070.04313.15
5.1.50.0000.06013.15
5.1.40.0030.03013.15
5.1.30.0070.05013.15
5.1.20.0030.03713.15
5.1.10.0070.04313.15
5.1.00.0030.04313.15
5.0.50.0030.02313.15
5.0.40.0000.03013.15
5.0.30.0030.03013.15
5.0.20.0000.02313.15
5.0.10.0000.04013.15
5.0.00.0030.06713.15
4.4.90.0030.01313.15
4.4.80.0030.03013.15
4.4.70.0030.02713.15
4.4.60.0030.03313.15
4.4.50.0100.01313.15
4.4.40.0030.05313.15
4.4.30.0030.01713.15
4.4.20.0030.01713.15
4.4.10.0070.03013.15
4.4.00.0030.02313.15
4.3.110.0000.01713.15
4.3.100.0000.01713.15
4.3.90.0070.03013.15
4.3.80.0000.04713.15
4.3.70.0030.03313.15
4.3.60.0000.03713.15
4.3.50.0000.02013.15
4.3.40.0070.04713.15
4.3.30.0000.03713.15
4.3.20.0030.03713.15
4.3.10.0030.03313.15
4.3.00.0000.03013.15

preferences:
37.92 ms | 401 KiB | 5 Q