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, 1391212800); 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.55
8.3.50.0090.00721.15
8.3.40.0070.00719.25
8.3.30.0080.00820.52
8.3.20.0050.00220.39
8.3.10.0080.00022.05
8.3.00.0040.00422.27
8.2.180.0040.01816.75
8.2.170.0110.00322.96
8.2.160.0070.00722.33
8.2.150.0080.00024.18
8.2.140.0040.00424.66
8.2.130.0070.00026.16
8.2.120.0040.00420.95
8.2.110.0040.00422.24
8.2.100.0090.00318.22
8.2.90.0080.00019.60
8.2.80.0060.00319.66
8.2.70.0000.00818.13
8.2.60.0040.00418.18
8.2.50.0000.00918.25
8.2.40.0080.00018.53
8.2.30.0040.00419.64
8.2.20.0040.00418.24
8.2.10.0040.00418.20
8.2.00.0030.00518.21
8.1.280.0070.00725.92
8.1.270.0030.00623.99
8.1.260.0050.00326.35
8.1.250.0080.00028.09
8.1.240.0030.00624.04
8.1.230.0040.00819.92
8.1.220.0050.00317.86
8.1.210.0060.00318.77
8.1.200.0060.00317.73
8.1.190.0030.00617.78
8.1.180.0000.00818.10
8.1.170.0080.00018.99
8.1.160.0000.00719.04
8.1.150.0000.00719.05
8.1.140.0030.00517.86
8.1.130.0040.00418.02
8.1.120.0040.00317.81
8.1.110.0030.00517.87
8.1.100.0000.00817.90
8.1.90.0040.00417.76
8.1.80.0040.00417.76
8.1.70.0070.00017.75
8.1.60.0030.00617.87
8.1.50.0030.00517.90
8.1.40.0040.00417.84
8.1.30.0030.00617.95
8.1.20.0080.00017.93
8.1.10.0030.00517.95
8.1.00.0000.00917.97
8.0.300.0000.00718.77
8.0.290.0000.00717.43
8.0.280.0000.00718.68
8.0.270.0070.00017.59
8.0.260.0070.00017.39
8.0.250.0030.00317.39
8.0.240.0080.00017.48
8.0.230.0000.00717.38
8.0.220.0070.00017.28
8.0.210.0040.00417.36
8.0.200.0000.00617.36
8.0.190.0060.00317.28
8.0.180.0000.00717.36
8.0.170.0030.00617.38
8.0.160.0000.00717.28
8.0.150.0040.00417.30
8.0.140.0070.00017.27
8.0.130.0060.00013.66
8.0.120.0040.00417.28
8.0.110.0070.00017.35
8.0.100.0040.00417.38
8.0.90.0000.00817.24
8.0.80.0030.01117.42
8.0.70.0040.00417.32
8.0.60.0030.00517.23
8.0.50.0020.00517.37
8.0.30.0080.01217.58
8.0.20.0170.00517.45
8.0.10.0040.00417.27
8.0.00.0140.00517.23
7.4.330.0000.00516.89
7.4.320.0070.00016.83
7.4.300.0000.00716.79
7.4.290.0030.00316.86
7.4.280.0000.00716.92
7.4.270.0030.00316.81
7.4.260.0050.00013.59
7.4.250.0000.00716.70
7.4.240.0060.00216.91
7.4.230.0070.00016.73
7.4.220.0060.01416.82
7.4.210.0060.00916.91
7.4.200.0000.00716.94
7.4.190.0040.00417.10
7.4.160.0160.00316.87
7.4.150.0130.00317.40
7.4.140.0100.00917.86
7.4.130.0120.00916.93
7.4.120.0100.00716.93
7.4.110.0140.01016.75
7.4.100.0080.00816.88
7.4.90.0100.01316.94
7.4.80.0030.01519.39
7.4.70.0110.00516.97
7.4.60.0070.01016.91
7.4.50.0060.00316.97
7.4.40.0070.01022.77
7.4.30.0190.00416.80
7.4.00.0050.01415.34
7.3.330.0060.00013.67
7.3.320.0000.00513.48
7.3.310.0040.00416.57
7.3.300.0000.00716.58
7.3.290.0110.00416.68
7.3.280.0080.01116.67
7.3.270.0090.00917.40
7.3.260.0100.01618.24
7.3.250.0090.00916.71
7.3.240.0090.01216.79
7.3.230.0100.01016.66
7.3.210.0000.01717.03
7.3.200.0100.01319.39
7.3.190.0040.01516.96
7.3.180.0070.01016.90
7.3.170.0080.00816.91
7.3.160.0110.00716.83
7.3.120.0050.00915.17
7.3.110.0030.01314.83
7.3.100.0070.01015.00
7.3.90.0030.00615.07
7.3.80.0100.00014.96
7.3.70.0000.01415.10
7.3.60.0060.00915.16
7.3.50.0040.01115.06
7.3.40.0090.00615.07
7.3.30.0030.00915.00
7.3.20.0070.01017.03
7.3.10.0040.01116.81
7.3.00.0090.00616.93
7.2.330.0160.00617.06
7.2.320.0070.01017.13
7.2.310.0130.01017.03
7.2.300.0120.01216.85
7.2.290.0140.00416.80
7.2.250.0030.01015.55
7.2.240.0060.01315.20
7.2.230.0070.00715.24
7.2.220.0000.01415.36
7.2.210.0060.00415.37
7.2.200.0040.00715.48
7.2.190.0070.00715.03
7.2.180.0040.01115.42
7.2.170.0040.00715.25
7.2.00.0040.00819.67
7.1.330.0040.00815.91
7.1.320.0030.01015.89
7.1.310.0070.00715.93
7.1.300.0070.01015.90
7.1.290.0030.01215.73
7.1.280.0000.00915.94
7.1.270.0090.00316.06
7.1.260.0040.01116.03
7.1.100.0000.01418.38
7.1.70.0070.00017.47
7.1.60.0100.01319.17
7.1.50.0140.01017.26
7.1.00.0000.03722.40
7.0.200.0000.00817.06
7.0.140.0070.08722.00
7.0.80.0030.08319.96
7.0.70.0100.06719.95
7.0.60.0130.07319.96
7.0.50.0100.08320.34
7.0.40.0130.07320.07
7.0.30.0130.07319.95
7.0.20.0030.08019.95
7.0.10.0200.07019.98
7.0.00.0000.06020.13
5.6.280.0000.07320.93
5.6.230.0070.07320.61
5.6.220.0100.07320.67
5.6.210.0070.08020.69
5.6.200.0100.08720.96
5.6.190.0100.08021.12
5.6.180.0030.08321.11
5.6.170.0130.08021.02
5.6.160.0100.07721.10
5.6.150.0200.07320.95
5.6.140.0100.07721.04
5.6.130.0000.05321.06
5.6.120.0100.04721.15
5.6.110.0000.07721.06
5.6.100.0030.09021.07
5.6.90.0070.07720.95
5.6.80.0170.07020.57
5.6.70.0100.07320.46
5.6.60.0070.04320.39
5.6.50.0100.05320.36
5.6.40.0030.08720.42
5.6.30.0070.07320.34
5.6.20.0170.06720.40
5.6.10.0070.07720.54
5.6.00.0070.04320.46
5.5.370.0070.07720.52
5.5.360.0130.04720.45
5.5.350.0100.08020.44
5.5.340.0070.07720.89
5.5.330.0070.07020.80
5.5.320.0030.07320.95
5.5.310.0070.08720.85
5.5.300.0170.07020.78
5.5.290.0000.06020.93
5.5.280.0070.07720.81
5.5.270.0100.07720.74
5.5.260.0100.08020.90
5.5.250.0170.07720.68
5.5.240.0030.08720.21
5.5.230.0130.05320.27
5.5.220.0100.04320.18
5.5.210.0170.07020.23
5.5.200.0100.07720.25
5.5.190.0070.04720.15
5.5.180.0070.08320.25
5.5.160.0100.06720.14
5.5.150.0130.04320.20
5.5.140.0100.04320.28
5.5.130.0130.07320.14
5.5.120.0030.08320.25
5.5.110.0000.08720.16
5.5.100.0030.05720.10
5.5.90.0000.08020.09
5.5.80.0130.07019.96
5.5.70.0000.07720.17
5.5.60.0130.05320.01
5.5.50.0100.05320.07
5.5.40.0130.07320.11
5.5.30.0100.07320.13
5.5.20.0030.08720.05
5.5.10.0130.04320.02
5.5.00.0030.07020.02
5.4.450.0030.08319.53
5.4.440.0070.08019.44
5.4.430.0030.06719.23
5.4.420.0200.05319.20
5.4.410.0100.06319.12
5.4.400.0000.08719.18
5.4.390.0130.03719.19
5.4.380.0170.06319.05
5.4.370.0100.07319.24
5.4.360.0200.06719.13
5.4.350.0100.07319.23
5.4.340.0070.06718.87
5.4.320.0130.06719.14
5.4.310.0070.07018.85
5.4.300.0070.07319.23
5.4.290.0070.07018.85
5.4.280.0100.07019.25
5.4.270.0070.08019.24
5.4.260.0070.05319.18
5.4.250.0030.08019.12
5.4.240.0070.07319.17
5.4.230.0130.07019.03
5.4.220.0130.07718.96
5.4.210.0030.07719.02
5.4.200.0030.05019.01
5.4.190.0070.07719.16
5.4.180.0030.06319.11
5.4.170.0170.07319.04
5.4.160.0000.06318.86
5.4.150.0070.07019.21
5.4.140.0030.07016.47
5.4.130.0070.07316.55
5.4.120.0100.07016.50
5.4.110.0030.07316.32
5.4.100.0000.08316.39
5.4.90.0200.06016.55
5.4.80.0030.04316.54
5.4.70.0030.07716.47
5.4.60.0070.07316.48
5.4.50.0100.04016.39
5.4.40.0100.07716.53
5.4.30.0070.06716.48
5.4.20.0130.06716.36
5.4.10.0030.05316.48
5.4.00.0070.06715.81
5.3.290.0030.07714.61
5.3.280.0130.07314.58
5.3.270.0070.04014.61
5.3.260.0070.08314.68
5.3.250.0170.07314.69
5.3.240.0100.07014.56
5.3.230.0100.07014.68
5.3.220.0130.06714.70
5.3.210.0000.08014.58
5.3.200.0070.04714.64
5.3.190.0100.04314.65
5.3.180.0030.07314.59
5.3.170.0170.07014.68
5.3.160.0030.06714.60
5.3.150.0070.04314.68
5.3.140.0030.07714.69
5.3.130.0100.07314.63
5.3.120.0070.04714.57
5.3.110.0100.04014.59
5.3.100.0030.07314.07
5.3.90.0130.07314.07
5.3.80.0130.04014.13
5.3.70.0070.03314.14
5.3.60.0070.06313.96
5.3.50.0030.08014.07
5.3.40.0070.04314.08
5.3.30.0070.03313.82
5.3.20.0030.03713.80
5.3.10.0030.05013.79
5.3.00.0000.03713.76
5.2.170.0000.06011.27
5.2.160.0070.06311.05
5.2.150.0030.03011.17
5.2.140.0100.06311.28
5.2.130.0000.03010.98
5.2.120.0000.03011.13
5.2.110.0070.03011.02
5.2.100.0030.02711.26
5.2.90.0030.03011.05
5.2.80.0000.03311.18
5.2.70.0030.02711.23
5.2.60.0070.02011.00
5.2.50.0070.03711.05
5.2.40.0000.03011.02
5.2.30.0030.03010.89
5.2.20.0070.04011.04
5.2.10.0000.03010.91
5.2.00.0000.03010.60
5.1.60.0000.02710.10
5.1.50.0000.03310.10
5.1.40.0030.0279.88
5.1.30.0000.04310.45
5.1.20.0030.02710.49
5.1.10.0000.02710.14
5.1.00.0000.02710.17
5.0.50.0000.0238.66
5.0.40.0030.0178.45
5.0.30.0000.0438.32
5.0.20.0070.0178.22
5.0.10.0000.0408.23
5.0.00.0000.0378.04
4.4.90.0030.0307.30
4.4.80.0000.0137.30
4.4.70.0000.0177.30
4.4.60.0000.0237.30
4.4.50.0000.0177.30
4.4.40.0000.0507.30
4.4.30.0000.0307.30
4.4.20.0030.0137.30
4.4.10.0000.0177.30
4.4.00.0000.0237.30
4.3.110.0030.0307.30
4.3.100.0100.0207.30
4.3.90.0030.0237.30
4.3.80.0000.0407.30
4.3.70.0030.0137.30
4.3.60.0000.0177.30
4.3.50.0000.0177.30
4.3.40.0000.0577.30
4.3.30.0000.0237.30
4.3.20.0000.0137.30
4.3.10.0000.0177.30
4.3.00.0030.0107.30

preferences:
39.96 ms | 401 KiB | 5 Q