3v4l.org

run code in 300+ PHP versions simultaneously
<?php ini_set('display_errors', 'on'); define('DAY_WORK', 32400); // 9 * 60 * 60 define('HOUR_START_DAY', '08:30:00'); define('HOUR_END_DAY', '18:00:00'); // get begin and end dates of the full period $date_begin = '2015-10-04 08:00:00'; $date_end = '2015-10-05 18:00:00'; // keep the initial dates for later use $d1 = new DateTime($date_begin); $d2 = new DateTime($date_end); // and get the datePeriod from the 1st to the last day $period_start = new DateTime($d1->format('Y-m-d 00:00:00')); $period_end = new DateTime($d2->format('Y-m-d 23:59:59')); $interval = new DateInterval('P1D'); //$interval = new DateInterval('weekdays'); // 1 day interval to get all days between the period $period = new DatePeriod($period_start, $interval, $period_end); $worked_time = 0; $nb = 0; // for every worked day, add the hours you want foreach($period as $date){ $week_day = $date->format('w'); // 0 (for Sunday) through 6 (for Saturday) if (!in_array($week_day,array(0, 6))) { // if this is the first day or the last dy, you have to count only the worked hours if ($date->format('Y-m-d') == $d1->format('Y-m-d')) { $end_of_day_format = $date->format('Y-m-d '.HOUR_END_DAY); $d1_format = $d1->format('Y-m-d H:i:s'); $end_of_day = new DateTime($end_of_day_format); $diff = $end_of_day->diff($d1)->format("%H:%I:%S"); $diff = split(':', $diff); $diff = $diff[0]*3600 + $diff[1]*60 + $diff[0]; $worked_time += $diff; } else if ($date->format('Y-m-d') == $d2->format('Y-m-d')) { $start_of_day = new DateTime($date->format('Y-m-d '.HOUR_START_DAY)); $d2_format = $d2->format('Y-m-d H:i:s'); $end_of_day = new DateTime($end_of_day_format); $diff = $start_of_day->diff($d2)->format('%H:%I:%S'); $diff = split(':', $diff); $diff = $diff[0]*3600 + $diff[1]*60 + $diff[0]; $worked_time += $diff; } else { // otherwise, just count the full day of work $worked_time += DAY_WORK; } } if ($nb> 10) die("die ".$nb); } echo sprintf('Works from %s to %s, You worked %d hour(s)', $date_begin, $date_end, $worked_time/60/60);

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.00316.88
8.3.50.0070.01522.17
8.3.40.0040.01118.90
8.3.30.0110.00419.09
8.3.20.0050.00320.25
8.3.10.0030.00523.65
8.3.00.0050.00317.88
8.2.180.0080.00818.79
8.2.170.0100.00322.96
8.2.160.0140.00320.64
8.2.150.0050.00324.18
8.2.140.0050.00324.66
8.2.130.0050.00326.16
8.2.120.0040.00417.88
8.2.110.0060.00322.25
8.2.100.0060.00618.09
8.2.90.0030.00519.15
8.2.80.0050.00317.97
8.2.70.0080.00018.00
8.2.60.0000.00818.05
8.2.50.0040.00418.10
8.2.40.0040.00420.45
8.2.30.0000.00920.58
8.2.20.0080.00017.92
8.2.10.0040.00418.25
8.2.00.0070.00018.13
8.1.280.0040.01225.92
8.1.270.0090.00023.82
8.1.260.0060.00326.35
8.1.250.0050.00328.09
8.1.240.0140.00723.84
8.1.230.0110.00019.67
8.1.220.0040.00418.01
8.1.210.0060.00318.77
8.1.200.0030.00717.73
8.1.190.0040.00417.60
8.1.180.0040.00418.10
8.1.170.0060.00318.77
8.1.160.0000.00722.09
8.1.150.0040.00419.02
8.1.140.0030.00619.75
8.1.130.0000.00717.82
8.1.120.0030.00517.79
8.1.110.0000.00717.71
8.1.100.0000.00717.66
8.1.90.0070.00017.61
8.1.80.0080.00017.71
8.1.70.0000.00817.63
8.1.60.0080.00417.70
8.1.50.0040.00417.63
8.1.40.0030.00717.73
8.1.30.0000.00817.79
8.1.20.0050.00317.82
8.1.10.0000.00817.77
8.1.00.0060.00317.65
8.0.300.0030.00518.77
8.0.290.0000.00817.13
8.0.280.0030.00318.44
8.0.270.0030.00317.39
8.0.260.0030.00317.27
8.0.250.0000.00717.27
8.0.240.0000.00817.31
8.0.230.0000.00717.26
8.0.220.0050.00217.18
8.0.210.0000.00717.09
8.0.200.0080.00017.16
8.0.190.0000.00817.32
8.0.180.0040.00417.13
8.0.170.0070.00017.20
8.0.160.0000.00717.29
8.0.150.0020.00517.06
8.0.140.0000.00717.06
8.0.130.0060.00013.54
8.0.120.0000.00917.08
8.0.110.0000.00817.06
8.0.100.0000.00717.18
8.0.90.0040.00417.09
8.0.80.0070.00717.18
8.0.70.0050.00217.21
8.0.60.0050.00217.25
8.0.50.0000.00817.12
8.0.30.0130.00517.21
8.0.20.0110.01117.55
8.0.10.0000.00717.36
8.0.00.0150.00617.02
7.4.330.0000.00515.15
7.4.320.0040.00416.71
7.4.300.0060.00016.72
7.4.290.0030.00316.81
7.4.280.0030.00616.59
7.4.270.0000.00816.77
7.4.260.0060.00316.81
7.4.250.0000.00716.68
7.4.240.0020.00516.70
7.4.230.0030.00316.71
7.4.220.0090.00916.77
7.4.210.0040.01016.73
7.4.200.0050.00316.70
7.4.160.0230.00016.73
7.4.150.0120.00617.40
7.4.140.0180.02317.86
7.4.130.0190.00316.64
7.4.120.0070.01216.89
7.4.110.0070.01316.99
7.4.100.0170.00316.62
7.4.90.0140.00416.59
7.4.80.0120.00719.39
7.4.70.0130.00416.82
7.4.60.0070.01116.66
7.4.50.0060.00316.85
7.4.40.0070.01616.88
7.4.30.0060.01116.84
7.4.10.0060.01316.93
7.4.00.0030.01215.97
7.3.330.0050.00013.38
7.3.320.0050.00013.34
7.3.310.0000.00816.59
7.3.300.0000.00716.36
7.3.290.0030.00316.51
7.3.280.0110.00616.52
7.3.270.0060.01917.40
7.3.260.0100.00716.79
7.3.240.0100.00716.70
7.3.230.0170.00716.76
7.3.210.0120.00916.68
7.3.200.0090.00916.68
7.3.190.0120.00616.53
7.3.180.0050.01016.48
7.3.170.0120.00616.62
7.3.160.0090.01316.84
7.3.130.0060.00916.60
7.3.120.0150.00416.74
7.3.110.0070.01016.37
7.3.100.0130.00316.77
7.3.90.0030.01016.66
7.3.80.0080.00816.60
7.3.70.0030.00616.66
7.3.60.0100.00716.67
7.3.50.0030.00616.62
7.3.40.0000.01516.56
7.3.30.0030.01216.59
7.3.20.0120.00318.29
7.3.10.0060.00318.33
7.3.00.0060.01318.37
7.2.330.0100.01016.93
7.2.320.0090.00916.69
7.2.310.0150.00316.79
7.2.300.0100.00716.87
7.2.290.0030.01617.07
7.2.260.0100.01016.88
7.2.250.0070.01016.51
7.2.240.0110.00316.67
7.2.230.0120.00316.71
7.2.220.0030.01416.81
7.2.210.0030.00716.94
7.2.200.0060.00616.73
7.2.190.0030.01316.77
7.2.180.0000.01116.80
7.2.170.0030.01516.83
7.2.160.0070.01016.75
7.2.150.0030.01018.30
7.2.140.0060.00918.54
7.2.130.0030.01018.68
7.2.120.0080.00818.63
7.2.110.0030.01618.46
7.2.100.0030.01018.69
7.2.90.0060.00918.64
7.2.80.0090.00318.66
7.2.70.0090.00918.52
7.2.60.0020.01417.79
7.2.50.0040.00918.45
7.2.40.0070.00318.59
7.2.30.0030.01318.69
7.2.20.0070.01018.49
7.2.10.0060.01018.65
7.2.00.0070.01018.93
7.1.330.0100.00317.55
7.1.320.0040.00817.68
7.1.310.0030.01017.36
7.1.300.0000.01317.39
7.1.290.0090.00617.38
7.1.280.0120.00617.30
7.1.270.0030.01017.30
7.1.260.0080.00617.30
7.1.250.0040.00717.50
7.1.240.0090.00617.43
7.1.230.0040.00417.50
7.1.220.0090.00617.50
7.1.210.0070.00717.45
7.1.200.0050.01016.61
7.1.190.0150.00317.52
7.1.180.0080.00817.35
7.1.170.0000.01317.58
7.1.160.0040.01117.39
7.1.150.0040.01417.44
7.1.140.0070.00717.46
7.1.130.0060.00617.46
7.1.120.0030.01217.60
7.1.110.0090.00917.64
7.1.100.0030.01217.73
7.1.90.0080.01117.32
7.1.80.0120.00317.40
7.1.70.0070.00717.30
7.1.60.0090.01018.47
7.1.50.0100.00517.31
7.1.40.0110.00417.57
7.1.30.0080.00817.59
7.1.20.0070.00417.43
7.1.10.0060.00617.39
7.1.00.0050.04019.86
7.0.330.0100.00717.14
7.0.320.0090.00617.25
7.0.310.0070.01017.16
7.0.300.0110.00416.99
7.0.290.0100.00717.05
7.0.280.0070.00717.06
7.0.270.0030.00817.30
7.0.260.0040.01117.36
7.0.250.0120.00317.13
7.0.240.0110.00617.25
7.0.230.0070.00717.13
7.0.220.0040.01417.19
7.0.210.0030.01317.25
7.0.200.0220.00516.00
7.0.190.0110.00617.23
7.0.180.0110.00017.10
7.0.170.0060.01017.37
7.0.160.0030.01017.16
7.0.150.0060.00917.30
7.0.140.0070.00717.12
7.0.130.0060.00617.24
7.0.120.0080.00617.34
7.0.110.0000.01517.06
7.0.100.0040.00817.27
7.0.90.0040.00717.26
7.0.80.0060.00617.08
7.0.70.0030.01117.19
7.0.60.0100.03218.54
7.0.50.0020.02717.48
7.0.40.0110.04617.60
7.0.30.0110.02917.55
7.0.20.0130.04117.62
7.0.10.0020.04017.63
7.0.00.0050.02417.59
5.6.400.0060.00615.79
5.6.390.0030.01516.23
5.6.380.0030.01316.20
5.6.370.0060.00915.88
5.6.360.0040.00716.30
5.6.350.0080.00416.21
5.6.340.0070.00415.96
5.6.330.0110.00316.21
5.6.320.0060.01316.30
5.6.310.0070.01116.02
5.6.300.0100.00316.26
5.6.290.0000.01515.83
5.6.280.0050.03618.63
5.6.270.0080.00615.96
5.6.260.0000.01416.13
5.6.250.0120.00016.02
5.6.240.0100.00716.03
5.6.230.0070.01415.95
5.6.220.0060.01116.12
5.6.210.0050.02718.43
5.6.200.0070.04717.21
5.6.190.0050.05018.28
5.6.180.0070.02618.20
5.6.170.0130.02318.31
5.6.160.0070.04818.39
5.6.150.0110.02017.19
5.6.140.0050.02317.13
5.6.130.0060.03517.16
5.6.120.0110.02918.56
5.6.110.0070.05018.52
5.6.100.0060.04318.52
5.6.90.0120.02818.57
5.6.80.0090.04718.09
5.6.70.0040.01115.82
5.6.60.0060.00915.84
5.6.50.0070.01015.86
5.6.40.0090.00915.88
5.6.30.0030.01515.87
5.6.20.0030.01316.12
5.6.10.0090.00616.05
5.6.00.0090.00616.04
5.5.380.0000.01016.07
5.5.370.0070.01315.81
5.5.360.0070.01116.02
5.5.350.0220.04018.23
5.5.340.0020.03017.02
5.5.330.0090.04318.17
5.5.320.0150.02318.12
5.5.310.0130.04618.10
5.5.300.0050.04316.90
5.5.290.0080.04416.95
5.5.280.0050.04018.47
5.5.270.0030.03018.36
5.5.260.0050.03718.43
5.5.250.0110.04118.33
5.5.240.0090.03418.21
5.5.230.0030.00815.90
5.5.220.0000.01615.97
5.5.210.0090.00915.82
5.5.200.0000.01015.99
5.5.190.0060.00616.19
5.5.180.0000.01316.10
5.5.170.0090.00616.13
5.5.160.0070.00716.05
5.5.150.0080.00815.82
5.5.140.0080.01115.87
5.5.130.0070.01116.01
5.5.120.0030.00716.09
5.5.110.0070.00715.79
5.5.100.0110.00615.83
5.5.90.0030.01616.21
5.5.80.0080.01115.70
5.5.70.0030.01015.86
5.5.60.0060.01016.14
5.5.50.0080.00315.84
5.5.40.0030.00616.21
5.5.30.0100.00315.91
5.5.20.0130.00316.16
5.5.10.0070.00416.09
5.5.00.0090.00315.77

preferences:
68.24 ms | 401 KiB | 5 Q