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++) { 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 = $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.00418.80
8.3.50.0140.00221.27
8.3.40.0060.00919.04
8.3.30.0040.01120.42
8.3.20.0040.00420.47
8.3.10.0080.00022.17
8.3.00.0040.00422.38
8.2.180.0080.01716.88
8.2.170.0110.00422.96
8.2.160.0070.00722.38
8.2.150.0000.00824.18
8.2.140.0080.00024.66
8.2.130.0040.00426.16
8.2.120.0070.00020.91
8.2.110.0060.00320.29
8.2.100.0080.00418.16
8.2.90.0000.00819.28
8.2.80.0040.00419.46
8.2.70.0050.00318.00
8.2.60.0050.00318.05
8.2.50.0060.00318.07
8.2.40.0040.00418.40
8.2.30.0060.00319.47
8.2.20.0000.00818.07
8.2.10.0000.00818.14
8.2.00.0000.00818.04
8.1.280.0100.01025.92
8.1.270.0050.00323.99
8.1.260.0040.00426.35
8.1.250.0000.00828.09
8.1.240.0060.00323.89
8.1.230.0060.00621.04
8.1.220.0060.00317.89
8.1.210.0080.00018.77
8.1.200.0070.00317.60
8.1.190.0040.00417.91
8.1.180.0040.00418.10
8.1.170.0030.00518.81
8.1.160.0000.00719.04
8.1.150.0030.00618.95
8.1.140.0050.00217.68
8.1.130.0030.00318.13
8.1.120.0040.00417.82
8.1.110.0040.00417.84
8.1.100.0000.00717.71
8.1.90.0040.00417.80
8.1.80.0000.00717.81
8.1.70.0070.00017.77
8.1.60.0040.00417.88
8.1.50.0030.00517.79
8.1.40.0000.00917.84
8.1.30.0000.00817.88
8.1.20.0040.00417.99
8.1.10.0020.00517.82
8.1.00.0000.00817.91
8.0.300.0050.00218.96
8.0.290.0040.00417.55
8.0.280.0030.00618.75
8.0.270.0070.00017.48
8.0.260.0000.00717.10
8.0.250.0040.00417.34
8.0.240.0030.00517.25
8.0.230.0000.00717.25
8.0.220.0030.00317.38
8.0.210.0070.00017.29
8.0.200.0000.00717.40
8.0.190.0040.00417.42
8.0.180.0040.00417.35
8.0.170.0040.00417.20
8.0.160.0070.00017.23
8.0.150.0000.00717.27
8.0.140.0020.00517.27
8.0.130.0060.00013.76
8.0.120.0030.00517.27
8.0.110.0000.00717.29
8.0.100.0040.00417.09
8.0.90.0040.00417.26
8.0.80.0130.00717.35
8.0.70.0000.00717.28
8.0.60.0000.00717.32
8.0.50.0080.00017.20
8.0.30.0120.00617.29
8.0.20.0160.00517.54
8.0.10.0000.00717.38
8.0.00.0090.01117.28
7.4.330.0000.00516.96
7.4.320.0000.00616.79
7.4.300.0030.00316.72
7.4.290.0030.00316.79
7.4.280.0000.00716.88
7.4.270.0000.00716.75
7.4.260.0000.00713.50
7.4.250.0040.00416.75
7.4.240.0070.00016.77
7.4.230.0000.00716.74
7.4.220.0060.02016.79
7.4.210.0090.00716.86
7.4.200.0000.00717.01
7.4.190.0000.00717.03
7.4.160.0040.01516.87
7.4.150.0110.00717.40
7.4.140.0100.00817.86
7.4.130.0140.00516.86
7.4.120.0100.00616.88
7.4.110.0150.00416.77
7.4.100.0060.01216.78
7.4.90.0070.01016.87
7.4.80.0110.01019.39
7.4.70.0040.01216.79
7.4.60.0150.00616.84
7.4.50.0040.00416.54
7.4.40.0040.01122.77
7.4.30.0060.01116.77
7.4.00.0000.01215.21
7.3.330.0000.00613.58
7.3.320.0000.00513.72
7.3.310.0040.00416.71
7.3.300.0070.00016.59
7.3.290.0070.00716.67
7.3.280.0100.00616.63
7.3.270.0220.00017.40
7.3.260.0090.00918.24
7.3.250.0120.00616.76
7.3.240.0100.00716.78
7.3.230.0100.00716.92
7.3.210.0100.00716.77
7.3.200.0070.01019.39
7.3.190.0130.01016.77
7.3.180.0110.00416.84
7.3.170.0110.00716.76
7.3.160.0060.00916.73
7.3.120.0030.00915.08
7.2.330.0000.01716.71
7.2.320.0100.01317.10
7.2.310.0080.01516.93
7.2.300.0160.00616.83
7.2.290.0140.00317.16
7.1.70.0070.00317.11
7.1.60.0070.01919.17
7.1.50.0130.01316.94
7.1.00.0030.03322.54
7.0.200.0000.00817.07
7.0.140.0170.06322.10
7.0.90.0400.08719.93
7.0.80.0430.03719.89
7.0.70.0530.07019.86
7.0.60.0530.07019.96
7.0.50.0600.06320.23
7.0.40.0070.09020.02
7.0.30.0070.08020.18
7.0.20.0070.08720.18
7.0.10.0030.09320.10
7.0.00.0030.08020.09
5.6.280.0070.06720.92
5.6.240.0100.04020.62
5.6.230.0130.06720.58
5.6.220.0070.08720.60
5.6.210.0000.05020.61
5.6.200.0000.05721.07
5.6.190.0130.08021.10
5.6.180.0100.06721.13
5.6.170.0070.08321.02
5.6.160.0200.06321.06
5.6.150.0000.08321.09
5.6.140.0070.09021.09
5.6.130.0130.08021.04
5.6.120.0070.08321.02
5.6.110.0030.05021.05
5.6.100.0100.07720.91
5.6.90.0070.05321.03
5.6.80.0100.03720.42
5.6.70.0100.06320.44
5.6.60.0200.07020.52
5.6.50.0100.06720.49
5.6.40.0130.07020.32
5.6.30.0030.08720.43
5.6.20.0070.08320.30
5.6.10.0030.06320.54
5.6.00.0070.07020.37
5.5.380.0030.08720.46
5.5.370.0100.03320.36
5.5.360.0070.08320.36
5.5.350.0070.05020.50
5.5.340.0100.08020.96
5.5.330.0070.05320.85
5.5.320.0000.04720.94
5.5.310.0200.07020.94
5.5.300.0100.08020.92
5.5.290.0130.07320.95
5.5.280.0030.07020.75
5.5.270.0130.07720.82
5.5.260.0200.07020.82
5.5.250.0070.04320.47
5.5.240.0100.04020.28
5.5.230.0030.05320.34
5.5.220.0100.07720.17
5.5.210.0100.07720.17
5.5.200.0070.07020.26
5.5.190.0100.06720.02
5.5.180.0130.07019.97
5.5.160.0130.03720.24
5.5.150.0030.08020.29
5.5.140.0100.07720.25
5.5.130.0070.06320.28
5.5.120.0000.05320.26
5.5.110.0100.07720.17
5.5.100.0130.07320.16
5.5.90.0100.06720.09
5.5.80.0070.03720.14
5.5.70.0000.07720.10
5.5.60.0070.07020.05
5.5.50.0200.06720.05
5.5.40.0100.06019.95
5.5.30.0270.03319.98
5.5.20.0070.08319.97
5.5.10.0030.04720.06
5.5.00.0030.07320.05
5.4.450.0070.08019.37
5.4.440.0030.04319.17
5.4.430.0030.08319.20
5.4.420.0000.06019.41
5.4.410.0130.06719.32
5.4.400.0130.05318.88
5.4.390.0000.08019.04
5.4.380.0030.08319.04
5.4.370.0030.07018.84
5.4.360.0070.07719.04
5.4.350.0030.06318.95
5.4.340.0100.06719.18
5.4.320.0100.04019.18
5.4.310.0030.07319.12
5.4.300.0200.06319.21
5.4.290.0070.04719.18
5.4.280.0130.03319.13
5.4.270.0130.05018.87
5.4.260.0100.07019.00
5.4.250.0070.06718.84
5.4.240.0100.03719.14
5.4.230.0030.07018.89
5.4.220.0000.05719.05
5.4.210.0070.07719.02
5.4.200.0100.06019.20
5.4.190.0130.03718.89
5.4.180.0070.07019.04
5.4.170.0070.08018.89
5.4.160.0100.07319.19
5.4.150.0100.04719.02
5.4.140.0130.06316.48
5.4.130.0130.06716.38
5.4.120.0070.07016.38
5.4.110.0100.06016.39
5.4.100.0000.04716.50
5.4.90.0100.06316.41
5.4.80.0030.07316.52
5.4.70.0030.07716.45
5.4.60.0100.07016.45
5.4.50.0070.03316.43
5.4.40.0070.03716.38
5.4.30.0170.04016.33
5.4.20.0100.03716.49
5.4.10.0070.04316.26
5.4.00.0070.06315.86
5.3.290.0000.07714.74
5.3.280.0070.07314.67
5.3.270.0130.04714.73
5.3.260.0130.06014.56
5.3.250.0030.05014.75
5.3.240.0000.05314.61
5.3.230.0000.06714.71
5.3.220.0100.07014.56
5.3.210.0130.07014.47
5.3.200.0000.08014.64
5.3.190.0100.07014.65
5.3.180.0000.07714.70
5.3.170.0070.05314.53
5.3.160.0130.07014.64
5.3.150.0070.07314.50
5.3.140.0030.04714.72
5.3.130.0130.05714.64
5.3.120.0030.08014.62
5.3.110.0130.07314.56
5.3.100.0030.05714.06
5.3.90.0100.07014.10
5.3.80.0000.07714.14
5.3.70.0100.07714.13
5.3.60.0100.03713.91
5.3.50.0030.07713.98
5.3.40.0070.05014.06
5.3.30.0100.06714.02
5.3.20.0030.03713.85
5.3.10.0030.07313.85
5.3.00.0000.04713.85
5.2.170.0030.03313.85
5.2.160.0070.06313.85
5.2.150.0070.04713.85
5.2.140.0000.05013.85
5.2.130.0100.05713.85
5.2.120.0030.03313.85
5.2.110.0100.04713.85
5.2.100.0070.05713.85
5.2.90.0070.05713.85
5.2.80.0030.06313.85
5.2.70.0030.06013.85
5.2.60.0030.03313.85
5.2.50.0170.05313.85
5.2.40.0030.03313.85
5.2.30.0000.03713.85
5.2.20.0130.04313.85
5.2.10.0070.06013.85
5.2.00.0030.03713.85
5.1.60.0070.05013.85
5.1.50.0070.05013.85
5.1.40.0070.05013.85
5.1.30.0000.05013.85
5.1.20.0000.06313.85
5.1.10.0030.05713.85
5.1.00.0000.04013.85
5.0.50.0030.04713.85
5.0.40.0000.04313.85
5.0.30.0000.06713.85
5.0.20.0030.04313.85
5.0.10.0000.04013.85
5.0.00.0000.03713.85
4.4.90.0000.02013.85
4.4.80.0000.04013.85
4.4.70.0030.03013.85
4.4.60.0000.03313.85
4.4.50.0030.03713.85
4.4.40.0030.04713.85
4.4.30.0070.02313.85
4.4.20.0030.03713.85
4.4.10.0100.02013.85
4.4.00.0070.02313.85
4.3.110.0030.02013.85
4.3.100.0070.03313.85
4.3.90.0070.03013.85
4.3.80.0000.05013.85
4.3.70.0000.02313.85
4.3.60.0070.02013.85
4.3.50.0030.03013.85
4.3.40.0000.03713.85
4.3.30.0000.03013.85
4.3.20.0000.03013.85
4.3.10.0000.02013.85
4.3.00.0000.03713.85

preferences:
42.47 ms | 401 KiB | 5 Q