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'); $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'); $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.0120.00616.88
8.3.50.0150.01022.07
8.3.40.0120.00318.92
8.3.30.0040.01119.29
8.3.20.0040.00420.29
8.3.10.0040.00423.48
8.3.00.0040.00419.02
8.2.180.0090.00616.63
8.2.170.0040.01122.96
8.2.160.0100.00320.40
8.2.150.0000.00824.18
8.2.140.0050.00324.66
8.2.130.0080.00026.16
8.2.120.0080.00020.72
8.2.110.0060.00322.11
8.2.100.0070.00417.84
8.2.90.0050.00319.35
8.2.80.0040.00417.97
8.2.70.0050.00517.88
8.2.60.0040.00417.93
8.2.50.0030.00618.07
8.2.40.0000.00821.06
8.2.30.0000.00718.29
8.2.20.0000.00717.84
8.2.10.0090.00018.11
8.2.00.0030.00517.96
8.1.280.0140.00725.92
8.1.270.0040.00423.89
8.1.260.0040.00426.35
8.1.250.0070.00028.09
8.1.240.0060.00322.11
8.1.230.0030.00719.01
8.1.220.0000.00817.80
8.1.210.0040.00418.77
8.1.200.0070.00417.48
8.1.190.0000.00817.47
8.1.180.0080.00018.10
8.1.170.0000.00818.71
8.1.160.0000.00721.96
8.1.150.0000.00818.77
8.1.140.0070.00017.63
8.1.130.0000.00717.79
8.1.120.0000.00717.58
8.1.110.0000.00817.61
8.1.100.0050.00317.61
8.1.90.0040.00417.67
8.1.80.0000.00817.68
8.1.70.0000.00717.61
8.1.60.0060.00317.57
8.1.50.0080.00017.71
8.1.40.0040.00417.56
8.1.30.0000.00917.69
8.1.20.0000.00817.83
8.1.10.0000.00817.68
8.1.00.0000.00717.79
8.0.300.0040.00418.77
8.0.290.0030.00517.05
8.0.280.0070.00018.56
8.0.270.0030.00317.36
8.0.260.0080.00017.39
8.0.250.0030.00317.25
8.0.240.0040.00417.21
8.0.230.0040.00417.22
8.0.220.0070.00017.12
8.0.210.0050.00317.14
8.0.200.0040.00417.14
8.0.190.0000.00717.05
8.0.180.0060.00317.14
8.0.170.0030.00517.07
8.0.160.0000.00717.01
8.0.150.0040.00417.13
8.0.140.0040.00417.10
8.0.130.0030.00313.41
8.0.120.0000.00817.12
8.0.110.0070.00017.21
8.0.100.0040.00417.07
8.0.90.0000.00717.04
8.0.80.0050.01017.15
8.0.70.0000.00717.02
8.0.60.0080.00017.07
8.0.50.0040.00417.07
8.0.30.0080.01517.37
8.0.20.0080.01017.47
8.0.10.0040.00417.13
8.0.00.0110.01416.96
7.4.330.0000.00515.03
7.4.320.0000.00716.68
7.4.300.0000.00916.57
7.4.290.0040.00416.69
7.4.280.0030.00616.55
7.4.270.0000.00816.84
7.4.260.0030.00316.75
7.4.250.0000.00716.69
7.4.240.0040.00316.71
7.4.230.0000.00716.86
7.4.220.0140.01416.74
7.4.210.0110.00516.88
7.4.200.0030.00616.43
7.4.190.0000.00716.77
7.4.160.0090.00616.66
7.4.150.0130.00617.40
7.4.140.0090.00817.86
7.4.130.0170.00016.71
7.4.120.0110.01116.71
7.4.110.0110.00716.73
7.4.100.0060.01216.53
7.4.90.0100.01316.62
7.4.80.0130.00619.39
7.4.70.0140.00316.59
7.4.60.0100.00716.77
7.4.50.0020.00216.88
7.4.40.0070.01016.64
7.4.30.0100.00616.53
7.4.10.0130.00615.01
7.4.00.0050.01115.19
7.3.330.0000.00613.27
7.3.320.0050.00013.21
7.3.310.0000.00716.29
7.3.300.0070.00016.35
7.3.290.0150.00316.48
7.3.280.0080.01216.47
7.3.270.0110.01517.40
7.3.260.0070.01016.68
7.3.250.0170.00316.70
7.3.240.0110.00616.43
7.3.230.0180.00016.41
7.3.210.0090.01516.40
7.3.200.0030.01419.39
7.3.190.0180.00316.40
7.3.180.0070.01316.46
7.3.170.0100.00616.79
7.3.160.0080.00816.55
7.3.130.0000.01415.02
7.3.120.0060.00715.25
7.3.110.0160.00315.15
7.3.100.0090.00314.87
7.3.90.0050.00315.05
7.3.80.0130.00314.91
7.3.70.0000.00915.09
7.3.60.0060.01014.88
7.3.50.0040.00715.02
7.3.40.0080.00414.96
7.3.30.0090.00614.96
7.3.20.0080.00416.73
7.3.10.0000.01216.75
7.3.00.0000.01116.84
7.2.330.0120.01216.92
7.2.320.0130.00617.01
7.2.310.0110.00616.85
7.2.300.0170.00717.01
7.2.290.0060.01616.95
7.2.260.0070.00715.16
7.2.250.0070.01314.96
7.2.240.0090.00315.28
7.2.230.0120.00314.75
7.2.220.0110.00415.40
7.2.210.0030.01015.26
7.2.200.0130.00315.32
7.2.190.0090.00615.13
7.2.180.0030.01415.17
7.2.170.0060.00915.28
7.2.160.0030.01315.41
7.2.150.0080.00417.02
7.2.140.0040.00717.13
7.2.130.0070.00717.03
7.2.120.0090.00617.23
7.2.110.0060.00616.84
7.2.100.0100.00317.06
7.2.90.0070.00717.14
7.2.80.0070.01117.13
7.2.70.0070.00317.07
7.2.60.0080.01117.01
7.2.50.0030.01317.21
7.2.40.0070.00717.16
7.2.30.0030.01317.04
7.2.20.0070.00317.14
7.2.10.0070.01016.88
7.2.00.0050.00818.43
7.1.330.0100.00315.86
7.1.320.0060.00315.86
7.1.310.0030.01016.00
7.1.300.0030.01015.77
7.1.290.0000.00916.09
7.1.280.0040.01215.71
7.1.270.0120.00315.76
7.1.260.0040.00715.83
7.1.250.0000.01015.92
7.1.240.0030.00615.84
7.1.230.0060.00616.07
7.1.220.0100.00315.85
7.1.210.0060.00615.97
7.1.200.0040.00716.03
7.1.190.0060.00915.84
7.1.180.0000.01515.70
7.1.170.0030.00715.88
7.1.160.0060.00615.88
7.1.150.0040.00715.70
7.1.140.0090.00615.79
7.1.130.0090.00616.05
7.1.120.0040.01115.65
7.1.110.0090.00915.82
7.1.100.0020.01216.86
7.1.90.0100.00716.13
7.1.80.0030.01216.03
7.1.70.0030.00716.72
7.1.60.0090.01017.80
7.1.50.0110.00816.46
7.1.40.0030.00615.91
7.1.30.0100.00015.85
7.1.20.0110.00015.73
7.1.10.0030.00615.80
7.1.00.0060.04019.14
7.0.330.0060.00615.56
7.0.320.0000.00815.38
7.0.310.0070.00715.70
7.0.300.0050.00515.14
7.0.290.0030.01015.39
7.0.280.0090.00615.58
7.0.270.0030.01315.41
7.0.260.0030.01015.51
7.0.250.0060.00615.70
7.0.240.0090.00915.52
7.0.230.0070.01015.51
7.0.220.0030.00915.59
7.0.210.0070.00315.66
7.0.200.0020.01216.35
7.0.190.0080.00415.49
7.0.180.0030.00915.75
7.0.170.0110.00415.60
7.0.160.0090.00315.62
7.0.150.0040.00415.41
7.0.140.0030.04118.76
7.0.130.0070.00315.38
7.0.120.0110.00315.41
7.0.110.0100.00315.36
7.0.100.0070.00715.54
7.0.90.0030.01015.37
7.0.80.0070.00715.59
7.0.70.0040.01115.45
7.0.60.0100.02517.82
7.0.50.0100.03516.63
7.0.40.0130.04117.01
7.0.30.0080.02616.84
7.0.20.0180.03816.66
7.0.10.0120.04216.82
7.0.00.0070.04816.94
5.6.400.0060.00614.74
5.6.390.0000.01814.29
5.6.380.0110.00414.27
5.6.370.0050.00514.70
5.6.360.0100.00714.63
5.6.350.0040.01114.26
5.6.340.0040.00714.63
5.6.330.0070.01014.18
5.6.320.0090.00314.32
5.6.310.0030.00914.42
5.6.300.0040.01114.28
5.6.290.0030.00714.53
5.6.280.0070.03617.73
5.6.270.0040.01114.55
5.6.260.0070.00714.26
5.6.250.0000.01114.36
5.6.240.0130.00314.70
5.6.230.0090.00314.77
5.6.220.0100.00314.30
5.6.210.0050.02617.40
5.6.200.0030.04316.44
5.6.190.0060.03217.32
5.6.180.0120.03017.50
5.6.170.0100.02517.36
5.6.160.0080.04617.46
5.6.150.0090.02916.47
5.6.140.0060.03116.27
5.6.130.0050.04316.36
5.6.120.0030.02917.69
5.6.110.0050.04317.79
5.6.100.0030.02317.82
5.6.90.0110.04317.78
5.6.80.0090.03417.51
5.6.70.0060.00614.45
5.6.60.0060.00914.47
5.6.50.0040.00814.37
5.6.40.0000.01614.45
5.6.30.0060.00614.47
5.6.20.0060.00314.41
5.6.10.0040.00714.29
5.6.00.0000.01014.62
5.5.380.0030.01014.36
5.5.370.0040.00814.56
5.5.360.0110.00414.40
5.5.350.0020.04717.47
5.5.340.0030.03216.28
5.5.330.0050.03017.22
5.5.320.0170.04617.32
5.5.310.0100.02517.37
5.5.300.0070.04116.11
5.5.290.0090.03816.14
5.5.280.0110.02217.47
5.5.270.0060.02217.80
5.5.260.0080.04317.52
5.5.250.0070.04217.33
5.5.240.0080.04017.20
5.5.230.0040.01414.51
5.5.220.0060.00914.55
5.5.210.0100.00314.44
5.5.200.0080.00414.48
5.5.190.0000.00914.52
5.5.180.0060.00314.46
5.5.170.0030.01214.28
5.5.160.0090.00314.17
5.5.150.0100.00714.55
5.5.140.0090.00614.39
5.5.130.0070.00714.20
5.5.120.0100.00714.45
5.5.110.0100.00314.45
5.5.100.0060.00814.26
5.5.90.0030.01014.53
5.5.80.0040.01114.45
5.5.70.0030.01414.43
5.5.60.0090.00313.95
5.5.50.0040.01114.27
5.5.40.0040.00814.53
5.5.30.0130.00314.49
5.5.20.0030.00614.01
5.5.10.0030.00714.68
5.5.00.0070.01114.33
5.4.450.0030.03715.64
5.4.440.0370.03215.70
5.4.430.0180.03415.66
5.4.420.0130.03415.58
5.4.410.0580.03315.56
5.4.400.0070.02715.37
5.4.390.0430.04015.36
5.4.380.0350.03715.22
5.4.370.0150.03015.24
5.4.360.0260.02515.29
5.4.350.0250.03015.18
5.4.340.0250.02515.26
5.4.330.0030.00711.81
5.4.320.0050.02212.15
5.4.310.0080.02512.14
5.4.300.0040.02512.15
5.4.290.0050.02712.14
5.4.280.0090.02212.09
5.4.270.0090.02212.09
5.4.260.0060.02712.09
5.4.250.0080.02412.09
5.4.240.0040.02912.09
5.4.230.0050.02812.09
5.4.220.0040.02812.09
5.4.210.0070.02612.09
5.4.200.0050.03812.09
5.4.190.0090.03712.08
5.4.180.0070.04512.08
5.4.170.0090.02712.09
5.4.160.0080.02712.09
5.4.150.0080.02612.09
5.4.140.0100.02711.93
5.4.130.0040.02911.92
5.4.120.0040.03111.90
5.4.110.0110.04511.90
5.4.100.0080.03011.90
5.4.90.0130.04511.90
5.4.80.0070.03611.90
5.4.70.0080.03211.90
5.4.60.0050.03111.90
5.4.50.0090.02611.90
5.4.40.0040.03011.89
5.4.30.0050.02811.89
5.4.20.0060.03011.89
5.4.10.0060.02611.89
5.4.00.0080.02711.64
5.3.290.0050.02312.31
5.3.280.0080.02512.26
5.3.270.0040.03012.27
5.3.260.0020.03512.26
5.3.250.0050.03112.27
5.3.240.0070.02212.27
5.3.230.0090.02612.26
5.3.220.0050.03112.25
5.3.210.0120.02712.25
5.3.200.0120.02512.24
5.3.190.0050.02912.25
5.3.180.0050.03012.24
5.3.170.0030.02512.24
5.3.160.0020.02512.24
5.3.150.0060.01912.24
5.3.140.0060.01812.24
5.3.130.0050.02412.23
5.3.120.0070.02512.23
5.3.110.0040.02412.24
5.3.100.0070.02311.96
5.3.90.0040.02611.95
5.3.80.0060.02011.94
5.3.70.0070.02311.95
5.3.60.0070.02711.94
5.3.50.0050.02211.91
5.3.40.0040.02511.91
5.3.30.0080.02411.89
5.3.20.0060.02411.78
5.3.10.0060.02211.77
5.3.00.0090.02711.76
5.2.170.0070.0409.21
5.2.160.0060.0399.21
5.2.150.0070.0399.21
5.2.140.0100.0549.20
5.2.130.0030.0429.16
5.2.120.0040.0419.17
5.2.110.0060.0389.18
5.2.100.0060.0399.18
5.2.90.0080.0399.17
5.2.80.0040.0459.16
5.2.70.0050.0439.16
5.2.60.0070.0399.12
5.2.50.0080.0409.09
5.2.40.0070.0369.07
5.2.30.0080.0399.05
5.2.20.0080.0359.03
5.2.10.0050.0388.96
5.2.00.0060.0398.82
5.1.60.0030.0358.09
5.1.50.0050.0348.09
5.1.40.0040.0358.06
5.1.30.0070.0368.42
5.1.20.0040.0398.44
5.1.10.0060.0338.16
5.1.00.0050.0358.16
5.0.50.0060.0256.65
5.0.40.0050.0276.51
5.0.30.0040.0436.32
5.0.20.0070.0246.32
5.0.10.0050.0266.30
5.0.00.0050.0396.29
4.4.90.0020.0244.78
4.4.80.0020.0234.75
4.4.70.0030.0214.76
4.4.60.0040.0204.76
4.4.50.0040.0204.77
4.4.40.0040.0324.71
4.4.30.0030.0204.76
4.4.20.0000.0254.85
4.4.10.0020.0224.85
4.4.00.0040.0304.76
4.3.110.0030.0224.67
4.3.100.0020.0224.66
4.3.90.0020.0214.63
4.3.80.0040.0304.59
4.3.70.0020.0214.63
4.3.60.0040.0194.63
4.3.50.0050.0194.63
4.3.40.0030.0324.53
4.3.30.0040.0193.31
4.3.20.0020.0213.29
4.3.10.0040.0193.25
4.3.00.0030.0237.36

preferences:
39.88 ms | 401 KiB | 5 Q