3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Initial datetimes $date1 = new DateTime('2012-03-22 11:29:16'); $date2 = new DateTime('2012-03-24 03:58:58'); // Set first datetime to midnight of next day $start = clone $date1; $start->modify('+1 day'); $start->modify('midnight'); // Set second datetime to midnight of that day $end = clone $date2; $end->modify('midnight'); // Count the number of full days between both dates $days = 0; // Loop through each day between two dates $interval = new DateInterval('P1D'); $period = new DatePeriod($start, $interval, $end); foreach ($period as $dt) { // If it is a weekend don't count it if (!in_array($dt->format('l'), array('Saturday', 'Sunday'))) { $days++; } } print "<pre>"; print_r($interval); print "</pre>"; // Assume 8 hour workdays $hours = $days * 8; // Get the number of hours worked on the first day $date1->modify('5:30 PM'); $diff = $date1->diff($start); $hours += $diff->h; // Get the number of hours worked the second day $date1->modify('8 AM'); $diff = $date2->diff($end); $hours += $diff->h; echo $hours;

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.0150.00317.00
8.3.50.0170.00318.42
8.3.40.0150.00018.69
8.3.30.0110.00418.96
8.3.20.0040.00420.33
8.3.10.0040.00423.64
8.3.00.0030.00619.40
8.2.180.0130.00716.75
8.2.170.0080.00822.96
8.2.160.0110.00420.39
8.2.150.0000.00824.18
8.2.140.0040.00424.66
8.2.130.0030.00526.16
8.2.120.0050.00517.88
8.2.110.0060.00320.55
8.2.100.0110.00018.09
8.2.90.0080.00019.48
8.2.80.0040.00417.97
8.2.70.0090.00017.63
8.2.60.0030.00518.15
8.2.50.0000.00818.07
8.2.40.0030.00619.52
8.2.30.0000.00720.64
8.2.20.0050.00317.90
8.2.10.0050.00318.34
8.2.00.0030.00518.27
8.1.280.0000.01825.92
8.1.270.0040.00424.04
8.1.260.0090.00026.35
8.1.250.0090.00028.09
8.1.240.0000.00923.95
8.1.230.0000.01117.77
8.1.220.0050.00317.91
8.1.210.0030.00518.77
8.1.200.0000.00917.61
8.1.190.0030.00717.48
8.1.180.0040.00418.10
8.1.170.0080.00019.07
8.1.160.0000.00722.04
8.1.150.0040.00420.79
8.1.140.0000.00819.61
8.1.130.0050.00217.86
8.1.120.0000.00717.74
8.1.110.0040.00417.73
8.1.100.0100.00017.64
8.1.90.0080.00017.73
8.1.80.0000.00717.70
8.1.70.0030.00317.65
8.1.60.0000.00717.79
8.1.50.0000.00817.62
8.1.40.0030.00717.66
8.1.30.0030.00517.82
8.1.20.0070.00017.89
8.1.10.0050.00317.79
8.1.00.0060.00317.75
8.0.300.0000.00718.77
8.0.290.0040.00417.00
8.0.280.0030.00318.71
8.0.270.0080.00017.41
8.0.260.0030.00317.36
8.0.250.0050.00317.21
8.0.240.0030.00317.19
8.0.230.0080.00017.17
8.0.220.0060.00317.19
8.0.210.0000.00717.17
8.0.200.0060.00017.26
8.0.190.0030.00517.25
8.0.180.0030.00317.16
8.0.170.0040.00417.11
8.0.160.0000.00717.29
8.0.150.0000.00717.15
8.0.140.0040.00417.18
8.0.130.0000.00613.57
8.0.120.0040.00417.09
8.0.110.0050.00217.14
8.0.100.0030.00517.06
8.0.90.0000.00717.01
8.0.80.0060.00917.27
8.0.70.0040.00417.20
8.0.60.0040.00417.00
8.0.50.0020.00517.24
8.0.30.0110.00617.43
8.0.20.0120.00717.45
8.0.10.0040.00417.16
8.0.00.0100.00817.03
7.4.330.0050.00015.08
7.4.320.0040.00416.88
7.4.300.0060.00016.83
7.4.290.0060.00316.71
7.4.280.0070.00016.68
7.4.270.0040.00416.80
7.4.260.0030.00716.80
7.4.250.0030.00516.71
7.4.240.0020.00616.78
7.4.230.0030.00316.81
7.4.220.0090.00916.80
7.4.210.0070.01216.73
7.4.200.0030.00316.81
7.4.160.0120.00616.82
7.4.150.0110.00817.40
7.4.140.0120.00617.86
7.4.130.0100.01016.81
7.4.120.0060.01116.76
7.4.110.0120.00616.77
7.4.100.0030.01516.84
7.4.90.0090.00916.80
7.4.80.0150.00719.39
7.4.70.0070.01016.65
7.4.60.0120.00416.65
7.4.50.0080.00016.93
7.4.40.0070.01416.71
7.4.30.0130.00316.81
7.4.00.0090.00515.39
7.3.330.0000.00513.24
7.3.320.0020.00213.28
7.3.310.0000.00716.54
7.3.300.0050.00316.48
7.3.290.0040.00416.44
7.3.280.0090.00816.49
7.3.270.0130.00317.40
7.3.260.0040.01716.95
7.3.250.0120.00616.64
7.3.240.0120.00616.64
7.3.230.0150.00316.82
7.3.210.0120.00416.54
7.3.200.0100.00716.80
7.3.190.0140.00316.74
7.3.180.0040.01216.60
7.3.170.0070.01316.54
7.3.160.0090.00916.70
7.3.120.0200.00015.17
7.3.110.0060.01214.79
7.3.100.0090.00315.17
7.3.90.0060.00614.97
7.3.80.0000.01315.00
7.3.70.0060.00615.18
7.3.60.0030.01015.13
7.3.50.0040.00815.06
7.3.40.0070.01115.17
7.3.30.0040.00715.13
7.3.20.0030.00916.75
7.3.10.0070.00816.89
7.3.00.0060.00316.93
7.2.330.0090.00917.02
7.2.320.0130.00617.11
7.2.310.0150.00817.01
7.2.300.0100.01016.91
7.2.290.0090.01416.88
7.2.250.0100.01015.55
7.2.240.0060.01015.40
7.2.230.0000.01815.32
7.2.220.0070.00715.25
7.2.210.0000.01615.28
7.2.200.0070.01115.46
7.2.190.0060.00315.05
7.2.180.0040.01215.21
7.2.170.0070.01115.16
7.2.60.0000.01616.80
7.2.00.0050.00519.88
7.1.330.0030.01016.02
7.1.320.0000.01615.86
7.1.310.0030.01015.70
7.1.300.0000.01515.91
7.1.290.0110.00716.00
7.1.280.0030.00616.05
7.1.270.0120.00416.06
7.1.260.0030.00615.87
7.1.200.0030.00815.97
7.1.100.0080.00318.02
7.1.70.0000.01217.11
7.1.60.0070.01719.43
7.1.50.0110.01117.10
7.1.00.0030.07722.51
7.0.200.0160.00914.85
7.0.60.0070.05320.02
7.0.50.0130.07317.89
7.0.40.0070.05720.40
7.0.30.0230.07020.02
7.0.20.0330.07720.12
7.0.10.0130.08020.04
7.0.00.0030.08720.27
5.6.280.0030.03320.93
5.6.210.0070.07320.61
5.6.200.0000.04318.09
5.6.190.0000.08720.78
5.6.180.0330.03320.35
5.6.170.0200.04020.46
5.6.160.0100.08720.48
5.6.150.0000.04718.14
5.6.140.0130.04018.07
5.6.130.0070.04018.22
5.6.120.0100.06321.02
5.6.110.0100.08021.11
5.6.100.0070.08021.00
5.6.90.0130.08021.10
5.6.80.0030.05720.43
5.5.350.2870.03320.37
5.5.340.0070.08017.93
5.5.330.0070.03720.43
5.5.320.0230.04020.21
5.5.310.0400.07020.32
5.5.300.0100.07717.97
5.5.290.0170.04717.96
5.5.280.0070.04020.89
5.5.270.0100.08320.64
5.5.260.0100.07320.89
5.5.250.0130.08320.59
5.5.240.0100.06720.18
5.4.450.0300.08719.63
5.4.440.0300.05319.57
5.4.430.0870.05719.59
5.4.420.0800.05319.48
5.4.410.0770.05319.20
5.4.400.0900.04719.00
5.4.390.0770.06319.07
5.4.380.0230.06719.07
5.4.370.0270.05718.84
5.4.360.0270.06718.84
5.4.350.0170.06019.24
5.4.340.0330.06719.26
5.4.320.0230.06719.02
5.4.310.0270.06318.73
5.4.300.0030.06719.29
5.4.290.0600.06319.13
5.4.280.0800.06719.00
5.4.270.0630.05319.07
5.4.260.0400.05718.73
5.4.250.0300.07318.73
5.4.240.0270.05718.95
5.4.230.0170.05019.14
5.4.220.0270.05019.24
5.4.210.0300.07319.03
5.4.200.0100.05319.15
5.4.190.0130.05719.23
5.4.180.0330.07718.83
5.4.170.0170.06319.09
5.4.160.0230.04319.04
5.4.150.0130.06019.24
5.4.140.0270.05016.29
5.4.130.0200.07316.16
5.4.120.0100.06316.39
5.4.110.0230.04716.54
5.4.100.0270.05016.61
5.4.90.0100.05016.61
5.4.80.0630.06016.60
5.4.70.1000.05016.54
5.4.60.1000.06316.48
5.4.50.0900.04716.51
5.4.40.0800.05016.46
5.4.30.0970.04716.57
5.4.20.0570.04716.09
5.4.10.0170.05016.49
5.4.00.0130.05015.82

preferences:
63.13 ms | 400 KiB | 5 Q