3v4l.org

run code in 300+ PHP versions simultaneously
<?php function addRollover($givenDate, $addtime, $dayStart, $dayEnd, $weekDaysOnly) { //Break the working day start and end times into hours, minuets $dayStart = explode(',', $dayStart); $dayEnd = explode(',', $dayEnd); //Create required datetime objects and hours interval $datetime = new DateTime($givenDate); $endofday = clone $datetime; $endofday->setTime($dayEnd[0], $dayEnd[1]); //set end of working day time $interval = 'PT'.$addtime.'H'; //Add hours onto initial given date $datetime->add(new DateInterval($interval)); //if initial date + hours is after the end of working day if($datetime > $endofday) { //get the difference between the initial date + interval and the end of working day in seconds $seconds = $datetime->getTimestamp()- $endofday->getTimestamp(); //Loop to next day while(true) { $endofday->add(new DateInterval('PT24H'));//Loop to next day by adding 24hrs $nextDay = $endofday->setTime($dayStart[0], $dayStart[1]);//Set day to working day start time //If the next day is on a weekend and the week day only param is true continue to add days if(in_array($nextDay->format('l'), array('Sunday','Saturday')) && $weekDaysOnly) { continue; } else //If not a weekend { $tmpDate = clone $nextDay; $tmpDate->setTime($dayEnd[0], $dayEnd[1]);//clone the next day and set time to working day end time $nextDay->add(new DateInterval('PT'.$seconds.'S')); //add the seconds onto the next day //if the next day time is later than the end of the working day continue loop if($nextDay > $tmpDate) { $seconds = $nextDay->getTimestamp()-$tmpDate->getTimestamp(); $endofday = clone $tmpDate; $endofday->setTime($dayStart[0], $dayStart[1]); } else //else return the new date. { return $endofday; } } } } return $datetime; } $currentTime = '2014-06-27 08:30:00'; $dayStart = '8,30'; $dayEnd = '17,30'; $future = addRollover($currentTime, 65, $dayStart, $dayEnd, true); echo "Results: </br>"; echo $future->format('Y-m-d H:i:s').'</br>';

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.01116.73
8.3.50.0070.01321.27
8.3.40.0120.00619.13
8.3.30.0070.00719.29
8.3.20.0040.00420.16
8.3.10.0080.00023.53
8.3.00.0040.00418.99
8.2.180.0000.02216.75
8.2.170.0090.00622.96
8.2.160.0100.01020.39
8.2.150.0040.00424.18
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0050.00319.90
8.2.110.0070.00322.25
8.2.100.0090.00317.95
8.2.90.0040.00418.16
8.2.80.0080.00018.16
8.2.70.0050.00318.05
8.2.60.0090.00017.80
8.2.50.0000.00818.10
8.2.40.0000.00720.63
8.2.30.0090.00018.10
8.2.20.0000.00818.02
8.2.10.0070.00018.27
8.2.00.0040.00418.02
8.1.280.0130.01025.92
8.1.270.0030.00522.01
8.1.260.0000.00826.35
8.1.250.0060.00328.09
8.1.240.0100.00019.45
8.1.230.0060.00622.73
8.1.220.0040.00417.79
8.1.210.0080.00018.85
8.1.200.0080.00317.13
8.1.190.0030.00517.48
8.1.180.0040.00418.10
8.1.170.0060.00318.65
8.1.160.0000.00722.05
8.1.150.0060.00318.73
8.1.140.0040.00417.58
8.1.130.0000.00717.81
8.1.120.0080.00017.62
8.1.110.0080.00017.66
8.1.100.0000.00717.71
8.1.90.0040.00417.58
8.1.80.0030.00517.68
8.1.70.0070.00017.65
8.1.60.0000.00817.76
8.1.50.0030.00617.67
8.1.40.0030.00617.66
8.1.30.0030.00517.87
8.1.20.0000.00817.78
8.1.10.0050.00217.74
8.1.00.0030.00517.75
8.0.300.0040.00420.15
8.0.290.0000.00717.00
8.0.280.0000.00818.45
8.0.270.0040.00416.98
8.0.260.0030.00317.27
8.0.250.0030.00317.21
8.0.240.0030.00317.21
8.0.230.0040.00417.30
8.0.220.0080.00017.07
8.0.210.0050.00217.26
8.0.200.0040.00417.14
8.0.190.0040.00417.14
8.0.180.0050.00317.09
8.0.170.0030.00617.13
8.0.160.0050.00217.13
8.0.150.0030.00517.11
8.0.140.0000.00717.12
8.0.130.0020.00613.52
8.0.120.0040.00417.18
8.0.110.0000.00717.16
8.0.100.0040.00417.29
8.0.90.0080.00017.05
8.0.80.0120.00317.06
8.0.70.0050.00317.22
8.0.60.0000.00917.25
8.0.50.0050.00317.11
8.0.30.0160.00617.30
8.0.20.0100.00917.40
8.0.10.0070.00017.24
8.0.00.0090.01217.15
7.4.330.0000.00515.07
7.4.320.0000.00716.59
7.4.300.0040.00416.66
7.4.290.0000.00716.77
7.4.280.0100.00016.75
7.4.270.0040.00416.65
7.4.260.0040.00416.55
7.4.250.0000.00716.53
7.4.240.0020.00516.71
7.4.230.0070.00016.77
7.4.220.0060.01316.70
7.4.210.0110.00616.71
7.4.200.0050.00216.79
7.4.190.0050.00216.82
7.4.160.0040.01116.92
7.4.150.0140.00417.40
7.4.140.0100.00817.86
7.4.130.0070.01016.65
7.4.120.0100.00716.71
7.4.110.0150.00416.66
7.4.100.0120.01316.84
7.4.90.0120.00616.65
7.4.80.0160.00919.39
7.4.70.0120.00416.73
7.4.60.0070.01116.90
7.4.50.0070.01616.69
7.4.40.0130.00916.71
7.4.30.0100.00916.61
7.4.20.0080.01216.60
7.4.10.0110.01216.78
7.4.00.0110.00816.22
7.3.330.0000.00513.37
7.3.320.0020.00213.45
7.3.310.0000.01016.67
7.3.300.0000.00716.46
7.3.290.0080.01116.61
7.3.280.0140.00616.62
7.3.270.0030.01417.40
7.3.260.0110.01116.76
7.3.250.0100.00816.61
7.3.240.0210.00616.56
7.3.230.0040.01416.55
7.3.210.0120.00616.55
7.3.200.0040.01219.39
7.3.190.0180.00016.57
7.3.180.0040.01216.59
7.3.170.0100.01116.61
7.3.160.0130.00616.65
7.3.150.0070.01316.69
7.3.140.0110.01016.76
7.3.130.0120.01316.60
7.3.120.0080.01216.01
7.3.110.0130.00516.62
7.3.100.0160.00816.69
7.3.90.0160.00716.63
7.3.80.0060.01316.52
7.3.70.0180.00616.56
7.3.60.0110.00816.57
7.3.50.0150.01116.58
7.3.40.0150.00916.66
7.3.30.0100.01016.56
7.3.20.0140.00516.64
7.3.10.0110.01216.62
7.3.00.0130.00916.58
7.2.330.0090.00916.83
7.2.320.0060.01616.89
7.2.310.0070.01117.00
7.2.300.0060.01116.80
7.2.290.0110.00916.63
7.2.280.0110.01016.80
7.2.270.0100.00916.81
7.2.260.0130.00716.82
7.2.250.0140.00516.83
7.2.240.0170.00516.70
7.2.230.0120.01116.86
7.2.220.0110.01116.87
7.2.210.0140.00916.83
7.2.200.0160.00516.89
7.2.190.0080.01216.73
7.2.180.0110.00916.84
7.2.170.0140.00916.78
7.2.160.0110.00816.79
7.2.150.0160.00816.93
7.2.140.0130.01116.81
7.2.130.0110.01016.88
7.2.120.0520.00915.64
7.2.110.0700.00615.75
7.2.100.0700.00815.71
7.2.90.0790.00715.63
7.2.80.0850.00915.71
7.2.70.0950.00915.82
7.2.60.0730.01115.89
7.2.50.0780.00815.88
7.2.40.0830.00915.95
7.2.30.0620.01015.88
7.2.20.0750.01215.76
7.2.10.0830.00615.92
7.2.00.0500.00816.43
7.1.330.0120.01615.69
7.1.320.0190.00815.70
7.1.310.0210.01015.67
7.1.300.0170.01015.80
7.1.290.0190.00715.78
7.1.280.0190.00815.74
7.1.270.0300.01315.81
7.1.260.0160.00915.72
7.1.250.0130.01415.75
7.1.240.0830.01214.73
7.1.230.0700.00614.72
7.1.220.1140.00914.80
7.1.210.0690.01014.78
7.1.200.0730.01014.61
7.1.190.0930.00814.74
7.1.180.0590.00714.74
7.1.170.1060.00714.69
7.1.160.0690.01014.77
7.1.150.0680.01114.82
7.1.140.0620.00814.74
7.1.130.0700.00714.75
7.1.120.0620.00814.69
7.1.110.0650.01014.75
7.1.100.0400.01015.40
7.1.90.0260.00914.64
7.1.80.0230.00814.81
7.1.70.0390.00815.21
7.1.60.0400.01015.55
7.1.50.0350.01015.22
7.1.40.0380.01114.70
7.1.30.1150.00714.75
7.1.20.0290.00814.74
7.1.10.0480.00914.83
7.1.00.0300.01816.00
7.0.330.0300.00515.41
7.0.320.0840.00614.26
7.0.310.0850.00714.35
7.0.300.0870.00614.41
7.0.290.0600.00714.43
7.0.280.0730.01014.41
7.0.270.0680.01014.37
7.0.260.0780.00914.45
7.0.250.0770.00914.40
7.0.240.0680.00914.49
7.0.230.0340.01014.52
7.0.220.0330.00614.42
7.0.210.0410.00814.53
7.0.200.0310.00814.79
7.0.190.0410.00614.45
7.0.180.0470.00914.47
7.0.170.0400.00714.58
7.0.160.0390.00814.52
7.0.150.0400.00914.48
7.0.140.0290.01815.74
7.0.130.0250.01014.48
7.0.120.0480.00814.54
7.0.110.0340.00914.46
7.0.100.0330.02115.43
7.0.90.0340.01915.41
7.0.80.0280.02015.42
7.0.70.0310.02115.41
7.0.60.0770.01615.35
7.0.50.0260.02115.46
7.0.40.0420.01515.47
7.0.30.0270.02115.44
7.0.20.0270.01515.38
7.0.10.0280.01715.44
7.0.00.0380.01915.43
5.6.400.0160.01316.21
5.6.390.0170.01016.03
5.6.380.0120.01115.25
5.6.370.0170.00815.30
5.6.360.0140.01215.16
5.6.350.0140.01015.21
5.6.340.0160.01015.36
5.6.330.0130.01115.26
5.6.320.0170.00815.29
5.6.310.0140.01315.19
5.6.300.0150.01115.35
5.6.290.0190.00715.37
5.6.280.0140.02016.36
5.6.270.0170.01015.36
5.6.260.0150.01115.32
5.6.250.0120.01816.13
5.6.240.0160.02116.11
5.6.230.0140.02316.16
5.6.220.0180.01716.14
5.6.210.0160.02316.15
5.6.200.0160.02016.22
5.6.190.0180.02116.19
5.6.180.0170.02116.28
5.6.170.0160.01716.17
5.6.160.0130.02416.20
5.6.150.0140.02416.20
5.6.140.0160.02016.17
5.6.130.0140.01616.11
5.6.120.0150.01616.19
5.6.110.0140.02216.24
5.6.100.0130.02316.11
5.6.90.0130.02316.27
5.6.80.0140.01816.05
5.6.70.0120.02416.00
5.6.60.0120.02116.08
5.6.50.0150.01916.11
5.6.40.0120.02516.11
5.6.30.0190.01816.05
5.6.20.0170.01615.88
5.6.10.0130.02516.08
5.6.00.0150.02116.06
5.5.380.0150.02014.81
5.5.370.0130.01514.71
5.5.360.0160.02014.76
5.5.350.0150.01414.80
5.5.340.0140.02214.82
5.5.330.0150.02014.87
5.5.320.0140.02114.87
5.5.310.0150.01914.84
5.5.300.0150.01714.84
5.5.290.0140.01914.84
5.5.280.0110.01714.85
5.5.270.0130.02014.82
5.5.260.0160.01814.85
5.5.250.0150.02014.82
5.5.240.0130.02114.77
5.5.230.0110.01914.67
5.5.220.0120.01814.77
5.5.210.0100.02314.73
5.5.200.0150.02014.72
5.5.190.0150.01414.74
5.5.180.0160.01614.70
5.5.170.0150.01115.13
5.5.160.0160.01714.72
5.5.150.0110.01814.73
5.5.140.0160.01614.69
5.5.130.0140.02014.73
5.5.120.0130.01814.70
5.5.110.0140.02114.77
5.5.100.0120.02414.74
5.5.90.0130.01514.72
5.5.80.0140.01814.70
5.5.70.0140.01814.76
5.5.60.0130.02214.63
5.5.50.0110.01714.72
5.5.40.0140.01614.60
5.5.30.0150.01914.61
5.5.20.0150.01714.67
5.5.10.0120.01614.72
5.5.00.0110.01914.72
5.4.450.0110.02113.55
5.4.440.0090.02113.56
5.4.430.0150.01613.55
5.4.420.0130.01413.57
5.4.410.0150.01413.58
5.4.400.0120.01813.50
5.4.390.0160.01013.47
5.4.380.0090.02113.49
5.4.370.0120.01713.47
5.4.360.0110.01813.49
5.4.350.0130.01613.49
5.4.340.0100.01913.49
5.4.330.0160.00612.35
5.4.320.0130.01713.47
5.4.310.0140.01713.50
5.4.300.0140.01713.47
5.4.290.0140.01613.51
5.4.280.0100.02113.44
5.4.270.0110.01813.46
5.4.260.0110.01813.46
5.4.250.0130.01913.42
5.4.240.0160.01613.45
5.4.230.0130.01613.48
5.4.220.0100.02113.47
5.4.210.0090.02013.50
5.4.200.0130.01513.42
5.4.190.0130.01613.49
5.4.180.0110.01913.50
5.4.170.0100.01813.42
5.4.160.0120.01313.47
5.4.150.0130.01813.42
5.4.140.0110.01913.06
5.4.130.0100.01913.03
5.4.120.0120.01613.06
5.4.110.0140.01613.07
5.4.100.0110.01813.04
5.4.90.0110.01813.02
5.4.80.0100.01913.00
5.4.70.0070.02113.09
5.4.60.0120.01513.04
5.4.50.0110.01813.03
5.4.40.0110.01813.08
5.4.30.0110.01913.07
5.4.20.0100.01613.07
5.4.10.0110.01413.07
5.4.00.0120.01812.96
5.3.290.0130.01712.93
5.3.280.0090.02112.86
5.3.270.0100.01812.89
5.3.260.0130.01612.91
5.3.250.0120.01812.90
5.3.240.0130.01612.84
5.3.230.0110.01812.86
5.3.220.0120.01112.88
5.3.210.0110.02012.86
5.3.200.0120.01612.84
5.3.190.0080.02112.84
5.3.180.0100.01912.91
5.3.170.0110.01612.89
5.3.160.0130.01212.91
5.3.150.0100.01312.91
5.3.140.0150.01112.86
5.3.130.0080.02112.85
5.3.120.0130.01712.86
5.3.110.0130.01712.89
5.3.100.0110.01712.79
5.3.90.0100.01412.79
5.3.80.0100.02012.71
5.3.70.0110.01112.73
5.3.60.0090.02012.76
5.3.50.0140.01412.78
5.3.40.0130.01412.79
5.3.30.0100.01312.82
5.3.20.0110.01812.68
5.3.10.0050.02212.63
5.3.00.0080.01912.67
5.2.170.0160.00312.34
5.2.160.0130.00712.36
5.2.150.0090.01012.35
5.2.140.0140.00812.41
5.2.130.0120.00912.19
5.2.120.0130.00412.14
5.2.110.0100.00812.18
5.2.100.0100.00912.20
5.2.90.0090.00612.14
5.2.80.0110.00712.13
5.2.70.0090.00912.04
5.2.60.0110.00412.10
5.2.50.0090.00812.08
5.2.40.0070.00912.22
5.2.30.0170.00012.08
5.2.20.0100.00711.96
5.2.10.0120.00511.89
5.2.00.0100.00611.88
5.1.60.0080.00711.48
5.1.50.0080.01111.48
5.1.40.0070.00911.48
5.1.30.0080.00711.48
5.1.20.0100.00711.48
5.1.10.0060.00911.48
5.1.00.0100.00611.48
5.0.50.0060.00711.48
5.0.40.0070.00811.48
5.0.30.0080.00611.48
5.0.20.0090.00311.48
5.0.10.0030.00911.48
5.0.00.0070.00511.48
4.4.90.0040.00511.48
4.4.80.0050.00311.48
4.4.70.0050.00411.48
4.4.60.0060.00311.48
4.4.50.0090.00011.48
4.4.40.0040.00311.48
4.4.30.0060.00411.48
4.4.20.0070.00211.48
4.4.10.0040.00511.48
4.4.00.0040.00511.48
4.3.110.0040.00511.48
4.3.100.0020.00611.48
4.3.90.0060.00211.48
4.3.80.0060.00311.48
4.3.70.0020.00811.48
4.3.60.0080.00211.48
4.3.50.0060.00311.48
4.3.40.0050.00311.48
4.3.30.0010.00611.48
4.3.20.0050.00111.48
4.3.10.0040.00411.48
4.3.00.0030.00411.48

preferences:
42.65 ms | 401 KiB | 5 Q