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]; $dateObj = new stdClass(); $dateObj->years = $years; $dateObj->months = $months; $dateObj->days = $days; $dateObj->hours = $hours; $dateObj->minutes = $minutes; $dateObj->seconds = $seconds; return $dateObj; } $mydate = calcDays(1388534400, 1454198400); echo $mydate->years;

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.0170.00318.35
8.3.50.0110.01121.21
8.3.40.0040.01119.21
8.3.30.0060.00920.34
8.3.20.0000.00720.30
8.3.10.0050.00321.95
8.3.00.0050.00322.39
8.2.180.0100.01017.00
8.2.170.0070.00722.96
8.2.160.0080.00622.13
8.2.150.0000.00824.18
8.2.140.0030.00524.66
8.2.130.0070.00026.16
8.2.120.0060.00320.91
8.2.110.0060.00322.25
8.2.100.0090.00318.28
8.2.90.0000.00918.13
8.2.80.0030.00718.18
8.2.70.0040.00418.30
8.2.60.0030.00518.18
8.2.50.0050.00318.10
8.2.40.0030.00620.59
8.2.30.0000.00819.57
8.2.20.0080.00017.99
8.2.10.0080.00018.14
8.2.00.0000.00918.01
8.1.280.0090.00625.92
8.1.270.0030.00623.99
8.1.260.0080.00026.35
8.1.250.0080.00028.09
8.1.240.0000.00822.32
8.1.230.0070.00419.35
8.1.220.0030.00617.91
8.1.210.0050.00418.77
8.1.200.0100.00017.73
8.1.190.0030.00617.63
8.1.180.0080.00018.10
8.1.170.0040.00419.03
8.1.160.0040.00419.16
8.1.150.0000.00818.97
8.1.140.0000.00717.75
8.1.130.0030.00318.10
8.1.120.0080.00017.71
8.1.110.0040.00417.72
8.1.100.0030.00517.80
8.1.90.0050.00317.72
8.1.80.0000.00717.64
8.1.70.0030.00317.79
8.1.60.0040.00417.89
8.1.50.0000.00717.81
8.1.40.0030.00617.78
8.1.30.0090.00017.89
8.1.20.0000.00917.91
8.1.10.0040.00417.82
8.1.00.0030.00517.68
8.0.300.0030.00620.10
8.0.290.0050.00317.25
8.0.280.0040.00418.62
8.0.270.0000.00717.37
8.0.260.0070.00017.22
8.0.250.0070.00017.42
8.0.240.0040.00417.39
8.0.230.0000.00817.36
8.0.220.0000.00717.36
8.0.210.0030.00317.20
8.0.200.0070.00017.23
8.0.190.0030.00517.42
8.0.180.0040.00417.29
8.0.170.0060.00317.28
8.0.160.0040.00417.25
8.0.150.0060.00317.20
8.0.140.0040.00417.27
8.0.130.0060.00013.69
8.0.120.0000.00717.21
8.0.110.0060.00317.36
8.0.100.0000.00817.26
8.0.90.0050.00317.16
8.0.80.0040.01117.25
8.0.70.0040.00417.18
8.0.60.0080.00017.36
8.0.50.0000.00817.23
8.0.30.0140.00617.33
8.0.20.0110.00817.44
8.0.10.0070.00017.41
8.0.00.0120.00717.12
7.4.330.0000.00516.82
7.4.320.0000.00616.71
7.4.300.0060.00016.87
7.4.290.0000.00716.80
7.4.280.0030.00316.93
7.4.270.0030.00316.77
7.4.260.0000.00513.61
7.4.250.0040.00416.70
7.4.240.0020.00516.78
7.4.230.0000.00716.89
7.4.220.0160.00316.82
7.4.210.0070.00916.86
7.4.200.0000.00716.73
7.4.190.0040.00416.76
7.4.160.0080.01216.77
7.4.150.0120.00617.40
7.4.140.0100.01117.86
7.4.130.0120.01016.91
7.4.120.0100.00616.75
7.4.110.0100.00716.80
7.4.100.0070.01016.88
7.4.90.0030.01616.75
7.4.80.0060.01219.39
7.4.70.0130.00616.78
7.4.60.0090.00916.70
7.4.50.0040.00416.75
7.4.40.0110.00622.77
7.4.30.0110.00616.80
7.4.00.0050.01215.29
7.3.330.0000.00513.45
7.3.320.0000.00513.41
7.3.310.0030.00316.64
7.3.300.0000.00716.61
7.3.290.0130.00716.62
7.3.280.0070.01316.63
7.3.270.0070.01517.40
7.3.260.0210.00918.24
7.3.250.0120.00816.65
7.3.240.0130.00716.56
7.3.230.0170.00716.74
7.3.210.0070.01016.80
7.3.200.0030.02019.39
7.3.190.0000.02216.89
7.3.180.0030.01316.85
7.3.170.0030.01316.77
7.3.160.0070.01116.73
7.3.120.0070.01115.26
7.3.110.0060.01215.10
7.3.100.0070.01015.21
7.3.90.0110.00715.14
7.3.80.0080.00415.14
7.3.70.0090.00615.23
7.3.60.0060.00614.95
7.3.50.0060.01015.09
7.3.40.0030.00915.18
7.3.30.0060.00615.02
7.3.20.0060.00616.82
7.3.10.0000.01216.64
7.3.00.0090.00016.97
7.2.330.0140.02417.05
7.2.320.0030.01316.78
7.2.310.0090.01216.63
7.2.300.0090.00917.05
7.2.290.0090.01317.07
7.2.250.0150.00315.36
7.2.240.0030.01715.29
7.2.230.0040.01115.36
7.2.220.0110.00715.30
7.2.210.0090.00615.43
7.2.200.0000.01815.31
7.2.190.0100.01015.34
7.2.180.0000.01815.52
7.2.170.0040.01115.36
7.2.00.0070.00319.74
7.1.330.0030.01016.03
7.1.320.0100.00715.91
7.1.310.0030.01216.12
7.1.300.0060.01216.15
7.1.290.0000.01315.93
7.1.280.0070.00715.89
7.1.270.0060.00616.08
7.1.260.0040.01116.07
7.1.100.0000.01218.46
7.1.70.0000.00917.46
7.1.60.0030.01017.57
7.1.50.0030.01317.03
7.1.00.0030.03322.57
7.0.200.0030.00616.69
7.0.140.0000.09321.90
7.0.100.0170.05020.00
7.0.90.0070.08719.93
7.0.80.0400.05719.96
7.0.70.0070.05020.17
7.0.60.0230.04719.93
7.0.50.0330.05020.27
7.0.40.0030.09720.14
7.0.30.0030.08020.00
7.0.20.0100.06020.14
7.0.10.0070.04720.12
7.0.00.0170.07320.14
5.6.280.0000.07720.91
5.6.250.0130.07020.82
5.6.240.0000.08320.62
5.6.230.0070.08720.69
5.6.220.0030.08020.68
5.6.210.0070.04320.62
5.6.200.0070.05020.98
5.6.190.0170.04721.06
5.6.180.0130.07721.12
5.6.170.0070.08721.12
5.6.160.0070.06321.05
5.6.150.0000.09020.91
5.6.140.0100.07721.02
5.6.130.0030.09021.07
5.6.120.0130.08021.07
5.6.110.0070.07020.96
5.6.100.0070.09021.08
5.6.90.0000.05021.11
5.6.80.0170.07320.48
5.6.70.0100.04720.43
5.6.60.0130.06020.35
5.6.50.0130.06720.45
5.6.40.0030.04320.39
5.6.30.0130.06020.32
5.6.20.0070.07020.31
5.6.10.0070.04320.48
5.6.00.0170.07020.47
5.5.380.0100.04720.36
5.5.370.0100.08020.48
5.5.360.0100.07720.42
5.5.350.0100.09020.45
5.5.340.0070.08320.73
5.5.330.0100.08020.80
5.5.320.0070.07020.75
5.5.310.0100.04020.86
5.5.300.0100.05020.77
5.5.290.0170.06020.89
5.5.280.0030.04320.87
5.5.270.0130.03720.64
5.5.260.0070.04020.89
5.5.250.0070.08020.76
5.5.240.0100.07020.15
5.5.230.0070.06020.26
5.5.220.0130.05720.15
5.5.210.0100.03720.04
5.5.200.0100.08020.18
5.5.190.0100.06020.02
5.5.180.0070.08720.01
5.5.160.0100.06720.14
5.5.150.0070.08320.24
5.5.140.0070.06020.25
5.5.130.0070.04320.29
5.5.120.0130.07320.25
5.5.110.0100.08320.23
5.5.100.0100.06020.12
5.5.90.0070.03720.11
5.5.80.0070.07719.96
5.5.70.0170.07719.98
5.5.60.0100.07020.07
5.5.50.0100.05319.96
5.5.40.0130.04320.17
5.5.30.0130.05320.07
5.5.20.0030.05320.11
5.5.10.0130.05720.07
5.5.00.0070.04320.12
5.4.450.0130.05319.43
5.4.440.0030.04319.22
5.4.430.0070.07019.48
5.4.420.0070.08719.50
5.4.410.0100.06719.22
5.4.400.0030.08319.14
5.4.390.0070.08019.05
5.4.380.0070.05718.95
5.4.370.0030.04019.18
5.4.360.0030.06319.13
5.4.350.0100.04718.95
5.4.340.0130.08719.24
5.4.320.0030.07019.16
5.4.310.0100.04719.20
5.4.300.0100.07018.95
5.4.290.0130.04719.16
5.4.280.0100.03719.23
5.4.270.0130.06719.03
5.4.260.0030.07019.20
5.4.250.0130.05019.02
5.4.240.0100.07719.04
5.4.230.0070.08019.04
5.4.220.0070.07018.87
5.4.210.0170.07719.02
5.4.200.0230.03718.89
5.4.190.0100.06319.02
5.4.180.0100.03718.89
5.4.170.0130.07319.02
5.4.160.0200.05018.93
5.4.150.0030.04019.16
5.4.140.0070.04016.32
5.4.130.0070.03716.43
5.4.120.0100.06016.33
5.4.110.0000.04316.56
5.4.100.0030.03716.55
5.4.90.0070.07016.53
5.4.80.0130.06316.51
5.4.70.0070.03316.36
5.4.60.0130.06716.36
5.4.50.0170.06016.48
5.4.40.0070.06716.41
5.4.30.0070.03716.48
5.4.20.0030.05316.36
5.4.10.0000.04016.44
5.4.00.0070.03315.89
5.3.290.0070.08014.70
5.3.280.0070.08014.62
5.3.270.0030.04314.64
5.3.260.0100.07314.66
5.3.250.0100.03314.58
5.3.240.0100.03314.56
5.3.230.0130.03014.64
5.3.220.0200.06314.58
5.3.210.0130.07014.63
5.3.200.0070.03314.61
5.3.190.0130.06014.52
5.3.180.0100.06014.69
5.3.170.0030.08314.51
5.3.160.0070.06314.70
5.3.150.0070.07314.55
5.3.140.0100.03314.56
5.3.130.0030.04714.63
5.3.120.0070.03714.58
5.3.110.0030.04314.55
5.3.100.0130.03014.03
5.3.90.0000.04314.06
5.3.80.0030.03314.05
5.3.70.0030.04014.18
5.3.60.0030.03713.96
5.3.50.0030.04013.86
5.3.40.0030.03314.11
5.3.30.0100.03013.99
5.3.20.0130.03013.84
5.3.10.0070.03013.68
5.3.00.0030.03713.69
5.2.170.0000.03011.30
5.2.160.0070.02711.26
5.2.150.0070.02311.26
5.2.140.0030.03011.26
5.2.130.0000.04011.26
5.2.120.0070.02711.26
5.2.110.0030.02711.26
5.2.100.0030.06011.26
5.2.90.0030.02711.26
5.2.80.0070.02011.26
5.2.70.0030.02311.26
5.2.60.0000.03011.26
5.2.50.0000.02711.26
5.2.40.0070.05311.26
5.2.30.0030.03311.26
5.2.20.0030.02311.26
5.2.10.0000.03011.26
5.2.00.0000.03711.26
5.1.60.0000.02711.26
5.1.50.0000.02311.26
5.1.40.0030.02011.26
5.1.30.0030.02311.26
5.1.20.0070.02311.26
5.1.10.0070.02311.26
5.1.00.0030.02011.26
5.0.50.0070.01711.26
5.0.40.0070.01311.26
5.0.30.0070.02711.26
5.0.20.0000.02011.26
5.0.10.0000.02011.26
5.0.00.0000.03311.26
4.4.90.0000.01311.26
4.4.80.0000.01311.26
4.4.70.0000.01311.26
4.4.60.0070.02011.26
4.4.50.0000.01311.26
4.4.40.0000.02711.26
4.4.30.0030.01711.26
4.4.20.0030.01311.26
4.4.10.0030.01011.26
4.4.00.0070.02011.26
4.3.110.0030.01311.26
4.3.100.0030.01011.26
4.3.90.0000.01711.26
4.3.80.0000.02311.26
4.3.70.0030.01711.26
4.3.60.0000.01311.26
4.3.50.0000.01311.26
4.3.40.0000.02311.26
4.3.30.0000.01711.26
4.3.20.0000.01711.26
4.3.10.0000.01311.26
4.3.00.0000.01311.26

preferences:
40.41 ms | 401 KiB | 5 Q