3v4l.org

run code in 300+ PHP versions simultaneously
<?php function calcDays($startdate, $enddate) { $first = $startdate < $enddate ? $startdate : $enddate; $second = $startdate < $enddate ? $enddate : $startdate; $inbetween = $second - $first; $i[0] = 60; $i[1] = 24; $i[2] = 7; $i[3] = date('t', strtotime('-1 month', $second)); $i[4] = date('L', strtotime('-1 year', $second)) ? 366 : 365; $i[5] = array(31, (date('L', strtotime('-1 year', $second)) ? 28 : 29), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); $years = floor($inbetween / $i[0] / $i[0] / $i[1] % $i[4]) >= $i[4] ? 1 : 0; echo $years; $months = 0; $days = 0; $temp = floor($inbetween / $i[0] / $i[0] / $i[1]); $tempMonth = date('n', strtotime('-1 year', $second)) - 1; for($n = 0; $n < 12; $n++) { if($temp >= $i[5][$tempMonth]) { $months += 1; $temp -= $i[5][$tempMonth]; } else { $days = $temp; break; } $tempMonth = $tempMonth < 10 ? $tempMonth + 1 : 0; } $hours = floor($inbetween / $i[0] / $i[0] % $i[1]); $minutes = floor($inbetween / $i[0] % $i[0]); $seconds = $inbetween % $i[0]; return $months . " months " . $days . " days " . $hours . " hours " . $minutes . " minutes " . $seconds . " seconds";; } echo calcDays(1388389157, 1420011556);

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.40.0150.00319.26
8.3.30.0110.00320.47
8.3.20.0040.00420.38
8.3.10.0080.00022.09
8.3.00.0070.00022.40
8.2.170.0040.01422.96
8.2.160.0030.01022.30
8.2.150.0030.00524.18
8.2.140.0040.00424.66
8.2.130.0090.00026.16
8.2.120.0000.00821.00
8.2.110.0100.00021.12
8.2.100.0110.00018.28
8.2.90.0040.00419.30
8.2.80.0000.00817.97
8.2.70.0000.00818.13
8.2.60.0040.00418.18
8.2.50.0050.00318.10
8.2.40.0060.00320.59
8.2.30.0070.00019.60
8.2.20.0050.00218.20
8.2.10.0040.00418.28
8.2.00.0000.00818.23
8.1.270.0000.00823.99
8.1.260.0060.00326.35
8.1.250.0040.00428.09
8.1.240.0060.00323.91
8.1.230.0090.00317.95
8.1.220.0050.00317.79
8.1.210.0080.00018.77
8.1.200.0110.00017.73
8.1.190.0000.00917.60
8.1.180.0000.00818.10
8.1.170.0060.00318.84
8.1.160.0000.00722.35
8.1.150.0040.00418.90
8.1.140.0030.00517.84
8.1.130.0000.00718.10
8.1.120.0020.00517.81
8.1.110.0000.00717.86
8.1.100.0000.00817.82
8.1.90.0040.00417.86
8.1.80.0040.00417.79
8.1.70.0030.00317.79
8.1.60.0000.00917.93
8.1.50.0000.00817.79
8.1.40.0030.00617.79
8.1.30.0030.00517.91
8.1.20.0050.00417.93
8.1.10.0030.00617.74
8.1.00.0040.00417.75
8.0.300.0080.00018.77
8.0.290.0030.00617.25
8.0.280.0040.00418.72
8.0.270.0040.00417.49
8.0.260.0050.00317.15
8.0.250.0000.00717.29
8.0.240.0030.00517.38
8.0.230.0030.00317.43
8.0.220.0030.00317.32
8.0.210.0040.00417.31
8.0.200.0040.00417.46
8.0.190.0040.00417.44
8.0.180.0030.00717.39
8.0.170.0000.00817.35
8.0.160.0040.00417.30
8.0.150.0000.00817.16
8.0.140.0040.00417.12
8.0.130.0030.00313.66
8.0.120.0040.00417.16
8.0.110.0050.00317.23
8.0.100.0040.00417.21
8.0.90.0000.00717.20
8.0.80.0030.01317.38
8.0.70.0040.00417.27
8.0.60.0030.00517.13
8.0.50.0070.00017.26
8.0.30.0070.01217.52
8.0.20.0030.01717.49
8.0.10.0030.00517.43
8.0.00.0080.01217.17
7.4.330.0050.00016.90
7.4.320.0060.00016.87
7.4.300.0040.00416.78
7.4.290.0030.00316.90
7.4.280.0040.00416.87
7.4.270.0070.00016.95
7.4.260.0050.00313.45
7.4.250.0040.00416.75
7.4.240.0040.00416.82
7.4.230.0080.00016.64
7.4.220.0130.00716.95
7.4.210.0080.00816.80
7.4.200.0070.00016.88
7.4.190.0000.00716.66
7.4.160.0150.00716.67
7.4.150.0200.00417.40
7.4.140.0090.00817.86
7.4.130.0080.01016.92
7.4.120.0130.00516.73
7.4.110.0170.00316.76
7.4.100.0030.01316.93
7.4.90.0030.01317.02
7.4.80.0130.00419.39
7.4.70.0070.01016.70
7.4.60.0110.00716.82
7.4.50.0040.00416.68
7.4.40.0070.01022.77
7.4.30.0100.00616.96
7.4.10.0060.00315.15
7.4.00.0080.00615.25
7.3.330.0060.00013.47
7.3.320.0020.00213.52
7.3.310.0030.00316.68
7.3.300.0030.00316.63
7.3.290.0030.01016.65
7.3.280.0120.00716.64
7.3.270.0140.00317.40
7.3.260.0090.00918.24
7.3.250.0070.01116.82
7.3.240.0090.00916.79
7.3.230.0030.01316.57
7.3.210.0060.01316.71
7.3.200.0200.00819.39
7.3.190.0070.01016.71
7.3.180.0090.00616.70
7.3.170.0130.00316.91
7.3.160.0100.00616.91
7.3.130.0100.00715.11
7.3.120.0050.01415.17
7.3.110.0040.01414.97
7.3.100.0080.00815.17
7.3.90.0050.01115.16
7.3.80.0090.00715.11
7.3.70.0030.00815.08
7.3.60.0090.00514.86
7.3.50.0020.01015.03
7.3.40.0080.00814.98
7.3.30.0080.00615.04
7.3.20.0030.01116.67
7.3.10.0040.00816.67
7.3.00.0100.00416.79
7.2.330.0090.00916.86
7.2.320.0160.00317.17
7.2.310.0110.00816.82
7.2.300.0030.01417.20
7.2.290.0060.01017.09
7.2.260.0080.00815.61
7.2.250.0070.01415.46
7.2.240.0030.01215.53
7.2.230.0050.01115.30
7.2.220.0080.00915.37
7.2.210.0120.00315.38
7.2.200.0060.00815.31
7.2.190.0100.00515.38
7.2.180.0070.00815.21
7.2.170.0030.01215.30
7.2.160.0060.00815.42
7.2.150.0050.01217.21
7.2.140.0080.00317.20
7.2.130.0070.00417.18
7.2.120.0080.00717.05
7.2.110.0060.00617.00
7.2.100.0090.00416.89
7.2.90.0080.00617.10
7.2.80.0050.01017.26
7.2.70.0050.00917.17
7.2.60.0050.00817.19
7.2.50.0070.00617.04
7.2.40.0090.00617.10
7.2.30.0080.00717.01
7.2.20.0110.00517.16
7.2.10.0050.01117.25
7.2.00.0090.00717.03
7.1.330.0060.00915.94
7.1.320.0070.00716.02
7.1.310.0080.00816.11
7.1.300.0060.00515.87
7.1.290.0060.00615.86
7.1.280.0080.00715.89
7.1.270.0060.00615.80
7.1.260.0060.00816.13
7.1.250.0040.00915.95
7.1.240.0060.00715.87
7.1.230.0090.00616.17
7.1.220.0070.00715.72
7.1.210.0110.00315.98
7.1.200.0020.00916.03
7.1.190.0100.00316.05
7.1.180.0100.00016.08
7.1.170.0000.01116.19
7.1.160.0040.00716.07
7.1.150.0070.00315.91
7.1.140.0070.00416.11
7.1.130.0030.00616.17
7.1.120.0030.01616.18
7.1.110.0060.00816.05
7.1.100.0030.01015.86
7.1.90.0070.00715.78
7.1.80.0130.00016.08
7.1.70.0110.00516.69
7.1.60.0140.00617.64
7.1.50.0080.01016.56
7.1.40.0070.00315.90
7.1.30.0000.01616.15
7.1.20.0060.00616.09
7.1.10.0000.01216.05
7.1.00.0050.02519.09
7.0.330.0000.01115.58
7.0.320.0040.00415.47
7.0.310.0120.00015.75
7.0.300.0000.01415.57
7.0.290.0070.00415.60
7.0.280.0070.00315.77
7.0.270.0070.01015.39
7.0.260.0090.00615.61
7.0.250.0030.01015.70
7.0.240.0040.00815.72
7.0.230.0050.00315.48
7.0.220.0060.00915.38
7.0.210.0070.01115.68
7.0.200.0030.00916.18
7.0.190.0030.00615.64
7.0.180.0140.00015.31
7.0.170.0070.01015.70
7.0.160.0030.01015.47
7.0.150.0120.00315.68
7.0.140.0100.03718.75
7.0.130.0060.01215.55
7.0.120.0090.00615.81
7.0.110.0110.00315.71
7.0.100.0070.02717.76
7.0.90.0050.02717.63
7.0.80.0030.02917.80
7.0.70.0070.04317.80
7.0.60.0080.04017.81
7.0.50.0050.04817.85
7.0.40.0050.02716.92
7.0.30.0090.03716.92
7.0.20.0100.02616.80
7.0.10.0040.04116.70
7.0.00.0070.04116.91
5.6.400.0030.01015.02
5.6.390.0070.01014.72
5.6.380.0030.01014.56
5.6.370.0040.01214.76
5.6.360.0040.01114.73
5.6.350.0040.00714.78
5.6.340.0040.01114.30
5.6.330.0060.00314.56
5.6.320.0000.01014.80
5.6.310.0060.01014.56
5.6.300.0030.00914.87
5.6.290.0000.01514.62
5.6.280.0050.03917.76
5.6.270.0070.00714.88
5.6.260.0090.00614.39
5.6.250.0070.04517.44
5.6.240.0070.03317.80
5.6.230.0080.04217.58
5.6.220.0020.05017.63
5.6.210.0120.03817.58
5.6.200.0100.04617.85
5.6.190.0050.04317.87
5.6.180.0030.04417.65
5.6.170.0050.04217.91
5.6.160.0050.04817.78
5.6.150.0070.03317.96
5.6.140.0050.03717.82
5.6.130.0140.02817.88
5.6.120.0150.03817.92
5.6.110.0050.04017.87
5.6.100.0050.04717.77
5.6.90.0070.04717.73
5.6.80.0090.03017.33
5.6.70.0140.03517.46
5.6.60.0030.02717.50
5.6.50.0070.02517.54
5.6.40.0080.04517.49
5.6.30.0050.04417.40
5.6.20.0150.03817.42
5.6.10.0070.04417.47
5.6.00.0080.02517.44
5.5.380.0020.05117.56
5.5.370.0080.04317.59
5.5.360.0020.03917.60
5.5.350.0060.04817.44
5.5.340.0130.03717.85
5.5.330.0140.03517.72
5.5.320.0050.05117.65
5.5.310.0080.03717.56
5.5.300.0030.05017.59
5.5.290.0060.04317.94
5.5.280.0060.04317.61
5.5.270.0120.04017.66
5.5.260.0070.04717.77
5.5.250.0070.04217.58
5.5.240.0080.04317.41
5.5.230.0110.02317.44
5.5.220.0110.03517.49
5.5.210.0120.03017.30
5.5.200.0080.04017.43
5.5.190.0040.04617.49
5.5.180.0100.04217.30
5.5.170.0070.00714.55
5.5.160.0050.02917.38
5.5.150.0070.04517.45
5.5.140.0080.04517.48
5.5.130.0080.04017.29
5.5.120.0110.03817.29
5.5.110.0050.02917.46
5.5.100.0100.04217.49
5.5.90.0040.02717.26
5.5.80.0070.04017.32
5.5.70.0030.04217.22
5.5.60.0130.02717.21
5.5.50.0070.03017.34
5.5.40.0060.04117.42
5.5.30.0080.03017.34
5.5.20.0050.04317.42
5.5.10.0000.03717.37
5.5.00.0020.02817.38
5.4.450.0110.04015.45
5.4.440.0030.02815.40
5.4.430.0050.04215.33
5.4.420.0090.04515.27
5.4.410.0080.03715.47
5.4.400.0070.04215.24
5.4.390.0060.03715.26
5.4.380.0070.04215.20
5.4.370.0020.04515.37
5.4.360.0090.02915.28
5.4.350.0050.04315.31
5.4.340.0050.03015.28
5.4.330.0060.00611.03
5.4.320.0000.03015.26
5.4.310.0020.03915.17
5.4.300.0070.03915.04
5.4.290.0100.03715.27
5.4.280.0110.03615.08
5.4.270.0050.02415.36
5.4.260.0030.02615.27
5.4.250.0070.02815.11
5.4.240.0050.02515.11
5.4.230.0090.03815.25
5.4.220.0100.01815.13
5.4.210.0060.02115.27
5.4.200.0080.03915.23
5.4.190.0070.03215.19
5.4.180.0020.02715.28
5.4.170.0040.02315.16
5.4.160.0030.02515.36
5.4.150.0040.02315.13
5.4.140.0030.03013.86
5.4.130.0100.02613.94
5.4.120.0020.03113.95
5.4.110.0060.02013.88
5.4.100.0050.02014.02
5.4.90.0070.02414.01
5.4.80.0030.04013.76
5.4.70.0050.01813.78
5.4.60.0060.01913.76
5.4.50.0030.02013.93
5.4.40.0070.01713.86
5.4.30.0090.01713.84
5.4.20.0020.02213.98
5.4.10.0050.02313.75
5.4.00.0020.02313.60
5.3.290.0110.03612.84
5.3.280.0030.03812.63
5.3.270.0060.02512.66
5.3.260.0010.02312.72
5.3.250.0070.01812.80
5.3.240.0030.02512.75
5.3.230.0040.02112.82
5.3.220.0060.02312.69
5.3.210.0020.02312.58
5.3.200.0050.01812.67
5.3.190.0000.02512.59
5.3.180.0030.02112.67
5.3.170.0050.02312.77
5.3.160.0060.01712.68
5.3.150.0030.02312.79
5.3.140.0030.02012.63
5.3.130.0080.02212.71
5.3.120.0030.02812.63
5.3.110.0020.02612.71
5.3.100.0020.03712.44
5.3.90.0030.02912.46
5.3.80.0030.01812.25
5.3.70.0030.02212.43
5.3.60.0000.02412.53
5.3.50.0070.01812.34
5.3.40.0030.02212.41
5.3.30.0020.02412.44
5.3.20.0010.02112.32
5.3.10.0050.01912.06
5.3.00.0060.03112.19
5.2.170.0030.05311.55
5.2.160.0030.02711.55
5.2.150.0030.02711.55
5.2.140.0070.02711.55
5.2.130.0000.03011.55
5.2.120.0100.02011.55
5.2.110.0070.03011.55
5.2.100.0000.03311.55
5.2.90.0030.02711.55
5.2.80.0030.02711.55
5.2.70.0070.02311.55
5.2.60.0030.03011.55
5.2.50.0070.02711.55
5.2.40.0030.04711.55
5.2.30.0030.03011.55
5.2.20.0070.02711.55
5.2.10.0000.03011.55
5.2.00.0000.04011.55
5.1.60.0000.03011.55
5.1.50.0070.03711.55
5.1.40.0070.04311.55
5.1.30.0000.05011.55
5.1.20.0000.05311.55
5.1.10.0000.06011.55
5.1.00.0070.05711.55
5.0.50.0030.02311.55
5.0.40.0100.03311.55
5.0.30.0030.05711.55
5.0.20.0030.02311.55
5.0.10.0030.02311.55
5.0.00.0030.03311.55
4.4.90.0030.01311.55
4.4.80.0030.01311.55
4.4.70.0000.01711.55
4.4.60.0030.01311.55
4.4.50.0030.01311.55
4.4.40.0030.05311.55
4.4.30.0030.02311.55
4.4.20.0070.01311.55
4.4.10.0000.02011.55
4.4.00.0000.04011.55
4.3.110.0070.03311.55
4.3.100.0000.04011.55
4.3.90.0100.03011.55
4.3.80.0070.05011.55
4.3.70.0070.03011.55
4.3.60.0000.02711.55
4.3.50.0070.03311.55
4.3.40.0070.04711.55
4.3.30.0030.03311.55
4.3.20.0000.03311.55
4.3.10.0000.03711.55
4.3.00.0000.03311.55

preferences:
41.35 ms | 400 KiB | 5 Q