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($temp >= $i[5][$tempMonth]) { $months += 1; $temp -= $i[5][$tempMonth]; } else { $days = $temp; break; } $tempMonth = $tempMonth < 10 ? $tempMonth + 1 : 0; } $years = date('Y', $second) - date('Y', $first) + $months / 12; $months = $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(1388389157, 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.40.0110.00419.04
8.3.30.0140.00020.34
8.3.20.0040.00420.41
8.3.10.0080.00022.10
8.3.00.0040.00422.39
8.2.170.0120.00322.96
8.2.160.0100.00322.29
8.2.150.0070.01025.66
8.2.140.0080.00024.66
8.2.130.0070.00026.16
8.2.120.0040.00421.05
8.2.110.0090.00022.32
8.2.100.0080.00418.09
8.2.90.0040.00419.34
8.2.80.0080.00019.40
8.2.70.0040.00418.00
8.2.60.0040.00418.04
8.2.50.0040.00418.13
8.2.40.0030.00618.40
8.2.30.0000.00719.50
8.2.20.0000.00818.18
8.2.10.0000.00818.12
8.2.00.0040.00418.21
8.1.270.0080.00024.04
8.1.260.0050.00326.35
8.1.250.0000.00828.09
8.1.240.0060.00322.24
8.1.230.0030.00921.04
8.1.220.0030.00617.74
8.1.210.0040.00418.77
8.1.200.0000.01017.60
8.1.190.0080.00017.66
8.1.180.0040.00418.10
8.1.170.0000.00818.82
8.1.160.0070.00019.12
8.1.150.0040.00418.90
8.1.140.0040.00417.79
8.1.130.0000.00718.01
8.1.120.0000.00717.88
8.1.110.0070.00017.70
8.1.100.0040.00417.79
8.1.90.0000.00817.77
8.1.80.0020.00517.69
8.1.70.0050.00317.70
8.1.60.0030.00617.77
8.1.50.0000.00817.81
8.1.40.0050.00217.80
8.1.30.0050.00317.97
8.1.20.0000.00817.94
8.1.10.0050.00317.85
8.1.00.0080.00017.83
8.0.300.0060.00318.77
8.0.290.0000.00717.43
8.0.280.0040.00418.63
8.0.270.0050.00317.38
8.0.260.0000.00717.23
8.0.250.0000.00717.33
8.0.240.0050.00317.34
8.0.230.0040.00417.36
8.0.220.0050.00217.30
8.0.210.0030.00317.35
8.0.200.0000.00617.23
8.0.190.0000.00817.36
8.0.180.0040.00417.23
8.0.170.0080.00017.23
8.0.160.0050.00217.25
8.0.150.0050.00217.32
8.0.140.0000.00817.12
8.0.130.0060.00013.75
8.0.120.0000.00817.18
8.0.110.0020.00517.33
8.0.100.0050.00217.38
8.0.90.0020.00517.37
8.0.80.0120.00617.26
8.0.70.0070.00017.27
8.0.60.0000.00817.09
8.0.50.0000.00717.13
8.0.30.0090.01117.38
8.0.20.0120.00817.48
8.0.10.0070.00017.41
8.0.00.0120.00717.23
7.4.330.0030.00316.86
7.4.320.0000.00716.75
7.4.300.0030.00316.75
7.4.290.0040.00416.82
7.4.280.0030.00316.79
7.4.270.0040.00316.92
7.4.260.0030.00313.45
7.4.250.0070.00016.65
7.4.240.0000.00816.83
7.4.230.0040.00416.79
7.4.220.0120.00616.84
7.4.210.0080.00916.90
7.4.200.0000.00716.98
7.4.190.0000.00717.07
7.4.160.0070.01016.79
7.4.150.0100.01017.40
7.4.140.0030.01617.86
7.4.130.0090.01416.83
7.4.120.0080.00916.73
7.4.110.0000.01816.76
7.4.100.0140.00416.77
7.4.90.0110.00616.76
7.4.80.0130.00719.39
7.4.70.0120.00616.87
7.4.60.0090.00616.88
7.4.50.0060.00316.88
7.4.40.0150.00322.77
7.4.30.0060.01516.93
7.4.00.0070.01115.47
7.3.330.0000.00513.60
7.3.320.0000.00613.46
7.3.310.0000.00716.66
7.3.300.0070.00016.66
7.3.290.0060.01316.62
7.3.280.0050.01216.66
7.3.270.0070.01317.40
7.3.260.0110.00818.24
7.3.250.0130.00616.67
7.3.240.0090.00916.97
7.3.230.0030.01716.89
7.3.210.0150.00616.71
7.3.200.0070.01019.39
7.3.190.0160.00616.86
7.3.180.0130.00316.89
7.3.170.0060.01016.79
7.3.160.0060.01216.72
7.3.120.0080.00415.30
7.2.330.0090.00917.18
7.2.320.0090.00916.71
7.2.310.0120.01017.19
7.2.300.0140.00716.69
7.2.290.0060.01017.07
7.2.00.0120.00319.79
7.1.100.0070.00718.50
7.1.70.0060.00317.45
7.1.60.0090.01519.17
7.1.50.0100.01617.23
7.1.00.0030.07322.48
7.0.200.0000.00717.02
7.0.140.0070.06721.95
7.0.90.0070.08720.16
7.0.80.0170.07019.92
7.0.70.0170.05020.05
7.0.60.0100.04019.95
7.0.50.0170.05020.36
7.0.40.0030.04320.10
7.0.30.0070.04020.13
7.0.20.0070.08020.09
7.0.10.0130.05020.04
7.0.00.0070.04020.03
5.6.280.0000.07721.04
5.6.240.0130.07720.53
5.6.230.0030.08320.56
5.6.220.0030.04320.53
5.6.210.0100.04020.77
5.6.200.0030.06021.13
5.6.190.0070.04020.98
5.6.180.0070.03721.10
5.6.170.0070.04320.96
5.6.160.0030.04321.06
5.6.150.0070.04321.04
5.6.140.0070.04721.05
5.6.130.0070.05720.96
5.6.120.0030.04721.12
5.6.110.0070.06721.12
5.6.100.0030.04321.02
5.6.90.0030.03721.13
5.6.80.0030.05320.43
5.6.70.0030.05320.42
5.6.60.0070.04020.52
5.6.50.0030.03320.48
5.6.40.0100.03720.48
5.6.30.0130.03320.49
5.6.20.0030.04320.36
5.6.10.0100.04020.49
5.6.00.0070.03020.33
5.5.380.0070.05020.41
5.5.370.0070.08320.38
5.5.360.0030.05020.38
5.5.350.0030.04720.44
5.5.340.0070.04020.93
5.5.330.0000.04320.92
5.5.320.0100.07320.95
5.5.310.0130.07020.91
5.5.300.0100.04720.85
5.5.290.0030.05020.66
5.5.280.0170.05020.88
5.5.270.0030.08020.86
5.5.260.0030.04320.79
5.5.250.0070.03320.66
5.5.240.0030.04020.33
5.5.230.0070.03320.16
5.5.220.0000.04320.30
5.5.210.0000.04320.27
5.5.200.0070.03020.26
5.5.190.0030.03720.09
5.5.180.0070.03720.14
5.5.160.0030.03320.23
5.5.150.0000.04320.23
5.5.140.0000.04320.14
5.5.130.0070.03720.17
5.5.120.0070.03720.16
5.5.110.0030.04020.00
5.5.100.0000.04720.07
5.5.90.0000.04020.18
5.5.80.0100.08020.10
5.5.70.0130.06320.11
5.5.60.0030.06319.95
5.5.50.0170.05720.14
5.5.40.0030.08020.05
5.5.30.0030.05720.17
5.5.20.0100.06320.05
5.5.10.0130.07020.11
5.5.00.0070.08320.10
5.4.450.0030.04019.20
5.4.440.0100.03719.23
5.4.430.0030.04019.46
5.4.420.0070.03019.45
5.4.410.0070.04719.40
5.4.400.0100.03018.88
5.4.390.0030.04019.04
5.4.380.0000.04319.04
5.4.370.0000.04019.14
5.4.360.0070.03018.90
5.4.350.0070.07019.18
5.4.340.0070.06019.16
5.4.320.0000.04019.06
5.4.310.0030.04319.11
5.4.300.0000.04018.85
5.4.290.0030.03718.87
5.4.280.0000.04319.23
5.4.270.0030.04018.94
5.4.260.0070.04019.23
5.4.250.0000.05719.20
5.4.240.0000.04019.09
5.4.230.0100.07318.87
5.4.220.0070.07319.18
5.4.210.0030.07719.11
5.4.200.0030.07319.03
5.4.190.0030.08019.13
5.4.180.0130.07319.08
5.4.170.0070.05719.11
5.4.160.0000.07318.82
5.4.150.0070.07719.01
5.4.140.0030.07316.54
5.4.130.0070.05716.46
5.4.120.0070.05716.47
5.4.110.0000.05316.56
5.4.100.0030.08016.55
5.4.90.0030.07316.56
5.4.80.0100.08316.50
5.4.70.0170.06016.43
5.4.60.0130.06716.45
5.4.50.0100.06716.40
5.4.40.0100.07716.37
5.4.30.0070.03716.34
5.4.20.0070.04316.33
5.4.10.0130.07016.46
5.4.00.0100.07015.91
5.3.290.0030.03314.78
5.3.280.0030.07314.61
5.3.270.0030.08714.70
5.3.260.0070.07714.57
5.3.250.0030.06314.68
5.3.240.0130.06714.70
5.3.230.0030.08014.62
5.3.220.0070.07314.69
5.3.210.0030.04014.61
5.3.200.0030.07014.52
5.3.190.0170.06714.61
5.3.180.0000.08314.57
5.3.170.0000.07314.54
5.3.160.0100.07314.52
5.3.150.0070.07714.70
5.3.140.0100.07314.57
5.3.130.0070.08014.55
5.3.120.0100.07014.49
5.3.110.0100.07714.61
5.3.100.0070.07714.20
5.3.90.0230.05014.10
5.3.80.0070.07014.10
5.3.70.0100.07014.16
5.3.60.0030.06013.93
5.3.50.0070.07714.02
5.3.40.0070.05314.02
5.3.30.0070.07313.91
5.3.20.0100.07313.62
5.3.10.0030.06013.68
5.3.00.0070.07713.79
5.2.170.0070.05711.09
5.2.160.0000.06711.23
5.2.150.0070.05311.03
5.2.140.0070.04711.25
5.2.130.0070.06311.13
5.2.120.0000.06711.26
5.2.110.0100.06011.15
5.2.100.0030.04011.04
5.2.90.0070.04711.11
5.2.80.0070.05311.24
5.2.70.0030.06711.03
5.2.60.0100.05310.98
5.2.50.0000.05710.97
5.2.40.0130.03711.02
5.2.30.0000.03710.89
5.2.20.0030.05710.93
5.2.10.0070.04310.97
5.2.00.0100.05310.75
5.1.60.0030.05310.33
5.1.50.0100.04310.33
5.1.40.0030.04710.33
5.1.30.0100.03710.33
5.1.20.0000.06010.33
5.1.10.0030.05010.33
5.1.00.0070.05710.33
5.0.50.0070.04310.33
5.0.40.0070.04010.33
5.0.30.0030.06710.33
5.0.20.0130.02710.33
5.0.10.0030.04310.33
5.0.00.0030.05310.33
4.4.90.0000.03310.33
4.4.80.0000.01710.33
4.4.70.0030.03310.33
4.4.60.0000.04010.33
4.4.50.0070.02310.33
4.4.40.0070.04710.33
4.4.30.0030.03010.33
4.4.20.0030.03710.33
4.4.10.0100.01710.33
4.4.00.0070.05010.33
4.3.110.0070.03010.33
4.3.100.0000.03010.33
4.3.90.0000.03010.33
4.3.80.0030.05310.33
4.3.70.0000.03710.33
4.3.60.0000.03010.33
4.3.50.0000.03010.33
4.3.40.0030.04710.33
4.3.30.0000.04010.33
4.3.20.0000.03710.33
4.3.10.0030.03710.33
4.3.00.0000.03710.33

preferences:
41.07 ms | 400 KiB | 5 Q