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); $months = 0; $days = 0; $temp = floor($inbetween / $i[0] / $i[0] / $i[1]); $tempDays = floor($temp % 365); $tempMonth = date('n', strtotime('-1 year', $second)) - 1; for($n = 0; $n < 12; $n++) { var_dump($tempDays); if($tempDays >= $i[5][$tempMonth]) { $months += 1; $tempDays -= $i[5][$tempMonth]; } else { $days = $tempDays; break; } $tempMonth = $tempMonth < 10 ? $tempMonth + 1 : 0; } $years = floor(date('Y', $second) - date('Y', $first) + $months / 12); $months = floor($months % 12); $hours = floor($inbetween / $i[0] / $i[0] % $i[1]); $minutes = floor($inbetween / $i[0] % $i[0]); $seconds = $inbetween % $i[0]; return $years . " years " . $months . " months " . $days . " days " . $hours . " hours " . $minutes . " minutes " . $seconds . " seconds"; } echo calcDays(1388789157, 1704094758);

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.0180.00318.65
8.3.50.0280.00421.27
8.3.40.0120.00319.09
8.3.30.0100.00320.34
8.3.20.0040.00420.20
8.3.10.0080.00022.08
8.3.00.0040.00422.26
8.2.180.0160.00318.79
8.2.170.0070.01122.96
8.2.160.0070.00722.21
8.2.150.0050.00324.18
8.2.140.0080.00024.66
8.2.130.0030.00526.16
8.2.120.0050.00321.07
8.2.110.0100.00021.19
8.2.100.0090.00318.28
8.2.90.0030.00519.47
8.2.80.0060.00317.97
8.2.70.0000.01018.00
8.2.60.0040.00418.05
8.2.50.0030.00618.10
8.2.40.0000.00720.72
8.2.30.0000.00718.27
8.2.20.0000.00918.09
8.2.10.0040.00418.16
8.2.00.0040.00418.21
8.1.280.0150.00025.92
8.1.270.0090.00023.99
8.1.260.0040.00426.35
8.1.250.0080.00028.09
8.1.240.0030.00624.04
8.1.230.0120.00019.67
8.1.220.0000.00817.91
8.1.210.0040.00418.77
8.1.200.0080.00317.60
8.1.190.0000.00917.66
8.1.180.0060.00318.10
8.1.170.0060.00318.77
8.1.160.0000.00722.22
8.1.150.0090.00019.03
8.1.140.0000.00817.80
8.1.130.0040.00418.01
8.1.120.0040.00417.70
8.1.110.0080.00017.70
8.1.100.0040.00417.80
8.1.90.0070.00017.78
8.1.80.0000.00717.85
8.1.70.0030.00317.80
8.1.60.0000.00817.77
8.1.50.0030.00617.76
8.1.40.0090.00017.70
8.1.30.0050.00317.97
8.1.20.0030.00617.86
8.1.10.0050.00317.86
8.1.00.0000.00717.77
8.0.300.0080.00018.84
8.0.290.0030.00517.25
8.0.280.0040.00418.72
8.0.270.0070.00017.36
8.0.260.0040.00417.28
8.0.250.0030.00317.27
8.0.240.0000.00817.27
8.0.230.0050.00317.28
8.0.220.0070.00017.24
8.0.210.0070.00017.31
8.0.200.0070.00017.23
8.0.190.0040.00417.27
8.0.180.0060.00317.31
8.0.170.0040.00417.20
8.0.160.0000.00717.18
8.0.150.0050.00217.12
8.0.140.0080.00017.27
8.0.130.0030.00313.63
8.0.120.0040.00417.25
8.0.110.0000.00817.15
8.0.100.0040.00417.18
8.0.90.0040.00317.11
8.0.80.0060.01217.30
8.0.70.0050.00317.23
8.0.60.0030.00617.18
8.0.50.0030.00517.29
8.0.30.0080.01217.56
8.0.20.0110.00717.63
8.0.10.0080.00017.29
8.0.00.0130.00517.01
7.4.330.0000.00517.01
7.4.320.0040.00416.87
7.4.300.0030.00316.84
7.4.290.0070.00016.88
7.4.280.0030.00316.79
7.4.270.0000.00716.88
7.4.260.0030.00313.51
7.4.250.0040.00416.78
7.4.240.0050.00216.78
7.4.230.0000.00716.77
7.4.220.0000.01816.92
7.4.210.0100.00716.82
7.4.200.0070.00016.74
7.4.190.0000.00716.98
7.4.160.0150.00316.96
7.4.150.0090.00917.40
7.4.140.0130.00517.86
7.4.130.0090.01016.70
7.4.120.0090.00916.74
7.4.110.0030.01516.84
7.4.100.0170.00416.81
7.4.90.0110.00616.86
7.4.80.0100.00719.39
7.4.70.0110.00616.84
7.4.60.0030.01416.90
7.4.50.0030.00616.79
7.4.40.0040.01122.77
7.4.30.0130.00616.82
7.4.00.0100.00715.12
7.3.330.0000.00513.61
7.3.320.0050.00013.73
7.3.310.0030.00316.82
7.3.300.0000.00716.62
7.3.290.0050.00916.66
7.3.280.0070.01116.63
7.3.270.0110.00617.40
7.3.260.0240.00018.24
7.3.250.0080.00916.85
7.3.240.0030.01416.74
7.3.230.0090.01116.73
7.3.210.0130.00316.77
7.3.200.0130.01019.39
7.3.190.0110.00817.00
7.3.180.0030.01316.79
7.3.170.0070.00716.85
7.3.160.0140.00316.78
7.3.120.0100.00315.25
7.2.330.0070.01116.75
7.2.320.0170.00717.17
7.2.310.0060.01316.68
7.2.300.0120.00916.82
7.2.290.0100.00717.20
7.2.60.0040.00817.23
7.2.00.0090.00619.46
7.1.200.0030.00616.05
7.1.100.0080.00418.34
7.1.70.0030.00917.09
7.1.60.0090.01519.17
7.1.50.0060.01917.02
7.1.00.0070.05322.32
7.0.200.0050.00216.96
7.0.140.0030.07722.22
7.0.100.0070.05019.93
7.0.90.0070.04320.03
7.0.80.0200.03719.97
7.0.70.0070.04019.93
7.0.60.0170.08021.71
7.0.50.0030.04722.15
7.0.40.0100.03320.01
7.0.30.0030.05320.14
7.0.20.0000.08020.05
7.0.10.0000.04020.13
7.0.00.0000.04020.14
5.6.280.0130.06321.09
5.6.250.0170.07320.71
5.6.240.0070.04020.70
5.6.230.0030.04720.77
5.6.220.0000.05020.57
5.6.210.0070.03320.63
5.6.200.0100.08021.05
5.6.190.0000.04021.09
5.6.180.0170.06021.09
5.6.170.0030.05321.05
5.6.160.0000.04321.05
5.6.150.0000.04321.02
5.6.140.0030.04021.02
5.6.130.0070.04320.99
5.6.120.0100.03721.12
5.6.110.0000.04321.03
5.6.100.0030.04021.09
5.6.90.0030.04321.11
5.6.80.0000.04320.37
5.6.70.0030.03720.41
5.6.60.0000.04320.49
5.6.50.0070.04020.45
5.6.40.0030.05320.32
5.6.30.0070.03320.48
5.6.20.0030.03320.31
5.6.10.0030.08720.38
5.6.00.0070.05720.32
5.5.380.0070.04320.37
5.5.370.0100.05020.39
5.5.360.0000.04020.39
5.5.350.0070.03320.46
5.5.340.0070.08020.91
5.5.330.0100.03020.89
5.5.320.0100.06320.90
5.5.310.0030.03720.91
5.5.300.0070.04020.79
5.5.290.0030.03720.93
5.5.280.0030.04320.82
5.5.270.0100.03720.79
5.5.260.0000.04320.90
5.5.250.0070.03320.75
5.5.240.0100.03320.29
5.5.230.0030.04020.27
5.5.220.0030.04320.16
5.5.210.0030.03320.20
5.5.200.0030.03720.15
5.5.190.0070.03720.21
5.5.180.0170.07320.27
5.5.160.0000.06320.27
5.5.150.0030.08020.14
5.5.140.0070.07719.99
5.5.130.0070.08020.31
5.5.120.0070.08020.28
5.5.110.0130.08020.29
5.5.100.0000.07720.17
5.5.90.0100.05720.09
5.5.80.0030.07320.03
5.5.70.0130.04720.18
5.5.60.0100.06720.08
5.5.50.0000.06720.15
5.5.40.0170.06320.17
5.5.30.0070.07720.11
5.5.20.0070.07320.13
5.5.10.0070.07720.00
5.5.00.0030.06720.06
5.4.450.0070.03719.20
5.4.440.0030.04319.19
5.4.430.0030.04019.39
5.4.420.0070.03719.56
5.4.410.0000.04719.40
5.4.400.0070.03318.88
5.4.390.0070.03319.19
5.4.380.0070.03319.12
5.4.370.0130.02719.22
5.4.360.0000.04719.04
5.4.350.0000.04319.21
5.4.340.0100.07719.12
5.4.320.0070.06718.89
5.4.310.0130.06718.95
5.4.300.0000.07318.85
5.4.290.0070.07319.16
5.4.280.0000.06719.13
5.4.270.0070.05019.09
5.4.260.0030.07318.87
5.4.250.0030.06718.94
5.4.240.0130.03719.13
5.4.230.0100.08019.02
5.4.220.0100.03719.13
5.4.210.0100.06319.14
5.4.200.0070.08018.87
5.4.190.0130.06319.17
5.4.180.0070.05718.85
5.4.170.0070.06719.03
5.4.160.0100.07319.06
5.4.150.0100.07019.16
5.4.140.0170.06016.25
5.4.130.0030.07016.52
5.4.120.0130.04016.43
5.4.110.0030.07716.56
5.4.100.0030.07016.45
5.4.90.0030.08016.41
5.4.80.0030.07016.43
5.4.70.0070.07016.37
5.4.60.0070.06316.37
5.4.50.0030.07316.37
5.4.40.0100.07316.42
5.4.30.0070.07316.41
5.4.20.0100.03316.32
5.4.10.0000.07716.25
5.4.00.0070.07015.72
5.3.290.0030.08714.61
5.3.280.0070.07714.59
5.3.270.0030.08014.60
5.3.260.0000.08714.63
5.3.250.0070.05714.71
5.3.240.0070.07314.74
5.3.230.0070.07314.76
5.3.220.0070.05314.55
5.3.210.0030.06714.64
5.3.200.0070.06714.65
5.3.190.0130.07014.65
5.3.180.0030.06714.59
5.3.170.0100.07314.53
5.3.160.0000.07314.64
5.3.150.0070.06714.60
5.3.140.0000.05014.61
5.3.130.0130.07314.61
5.3.120.0100.05314.63
5.3.110.0100.07314.66
5.3.100.0130.07014.01
5.3.90.0100.03013.99
5.3.80.0070.04014.07
5.3.70.0100.07014.10
5.3.60.0070.05714.05
5.3.50.0070.07314.06
5.3.40.0030.07314.11
5.3.30.0070.04013.82
5.3.20.0030.07313.85
5.3.10.0030.07713.66
5.3.00.0070.05713.69
5.2.170.0000.07011.30
5.2.160.0070.04011.08
5.2.150.0000.04011.08
5.2.140.0100.04711.08
5.2.130.0000.03011.23
5.2.120.0000.06311.24
5.2.110.0070.06011.23
5.2.100.0030.06011.19
5.2.90.0000.06311.14
5.2.80.0000.04711.01
5.2.70.0030.06011.15
5.2.60.0030.05711.13
5.2.50.0130.04711.03
5.2.40.0070.05711.07
5.2.30.0070.06010.86
5.2.20.0000.06010.84
5.2.10.0030.05710.94
5.2.00.0000.06010.75
5.1.60.0100.04710.07
5.1.50.0030.03010.11
5.1.40.0030.05310.14
5.1.30.0100.05010.48
5.1.20.0000.06310.29
5.1.10.0030.05710.18
5.1.00.0100.02710.18
5.0.50.0030.0409.17
5.0.40.0000.0309.17
5.0.30.0070.0579.17
5.0.20.0000.0409.17
5.0.10.0000.0379.17
5.0.00.0000.0679.17
4.4.90.0000.0339.17
4.4.80.0070.0309.17
4.4.70.0000.0309.17
4.4.60.0130.0239.17
4.4.50.0000.0209.17
4.4.40.0000.0539.17
4.4.30.0000.0309.17
4.4.20.0000.0179.17
4.4.10.0030.0339.17
4.4.00.0030.0539.17
4.3.110.0000.0379.17
4.3.100.0030.0279.17
4.3.90.0000.0379.17
4.3.80.0000.0279.17
4.3.70.0030.0209.17
4.3.60.0000.0179.17
4.3.50.0030.0339.17
4.3.40.0000.0539.17
4.3.30.0000.0379.17
4.3.20.0030.0179.17
4.3.10.0000.0379.17
4.3.00.0000.0379.17

preferences:
42.65 ms | 401 KiB | 5 Q