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); //$years = floor($inbetween / $i[0] / $i[0] / $i[1] % $i[4]) >= $i[4] ? 1 : 0; //echo $years; $months = 0; $days = 0; $temp = floor($inbetween / $i[0] / $i[0] / $i[1]); $tempMonth = date('n', strtotime('-1 year', $second)) - 1; for($n = 0; $n < 12; $n++) { if($temp >= $i[5][$tempMonth]) { $months += 1; $temp -= $i[5][$tempMonth]; } else { $days = $temp; break; } $tempMonth = $tempMonth < 10 ? $tempMonth + 1 : 0; } $years = $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, 1420097956);

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.0110.00718.68
8.3.50.0180.00421.27
8.3.40.0070.01019.23
8.3.30.0100.00320.29
8.3.20.0080.00020.29
8.3.10.0050.00322.21
8.3.00.0040.00422.40
8.2.180.0100.01316.75
8.2.170.0090.00922.96
8.2.160.0100.00322.30
8.2.150.0040.00424.18
8.2.140.0030.00624.66
8.2.130.0050.00326.16
8.2.120.0080.00020.92
8.2.110.0060.00322.23
8.2.100.0060.00618.09
8.2.90.0040.00419.38
8.2.80.0000.00819.59
8.2.70.0000.00817.88
8.2.60.0080.00018.29
8.2.50.0040.00418.07
8.2.40.0040.00418.46
8.2.30.0050.00219.49
8.2.20.0000.00818.20
8.2.10.0090.00018.15
8.2.00.0030.00518.21
8.1.270.0090.00023.99
8.1.260.0080.00026.35
8.1.250.0030.00628.09
8.1.240.0030.00623.90
8.1.230.0120.00020.92
8.1.220.0030.00517.85
8.1.210.0080.00018.77
8.1.200.0060.00317.60
8.1.190.0080.00017.78
8.1.180.0050.00318.10
8.1.170.0050.00318.57
8.1.160.0020.00519.05
8.1.150.0080.00018.99
8.1.140.0040.00417.85
8.1.130.0070.00017.96
8.1.120.0000.00717.78
8.1.110.0000.00817.84
8.1.100.0000.00817.86
8.1.90.0050.00217.73
8.1.80.0070.00017.77
8.1.70.0000.00717.78
8.1.60.0000.00817.88
8.1.50.0040.00417.82
8.1.40.0060.00317.78
8.1.30.0000.00717.94
8.1.20.0050.00317.84
8.1.10.0000.00717.89
8.1.00.0000.00817.74
8.0.300.0040.00418.96
8.0.290.0000.00817.43
8.0.280.0080.00018.73
8.0.270.0030.00417.36
8.0.260.0070.00017.22
8.0.250.0030.00317.41
8.0.240.0040.00417.37
8.0.230.0030.00317.32
8.0.220.0080.00017.30
8.0.210.0040.00417.27
8.0.200.0000.00617.38
8.0.190.0000.00917.35
8.0.180.0000.00717.29
8.0.170.0040.00417.37
8.0.160.0070.00017.20
8.0.150.0040.00417.23
8.0.140.0080.00017.26
8.0.130.0000.00613.60
8.0.120.0040.00417.16
8.0.110.0090.00017.33
8.0.100.0050.00317.20
8.0.90.0000.00717.22
8.0.80.0090.00617.24
8.0.70.0040.00417.16
8.0.60.0040.00417.35
8.0.50.0050.00317.23
8.0.30.0100.01017.37
8.0.20.0120.00717.48
8.0.10.0030.00517.24
8.0.00.0120.00817.05
7.4.330.0050.00016.95
7.4.320.0030.00316.79
7.4.300.0030.00316.90
7.4.290.0000.00716.86
7.4.280.0050.00316.87
7.4.270.0030.00616.88
7.4.260.0000.00513.52
7.4.250.0060.00316.74
7.4.240.0050.00216.86
7.4.230.0070.00016.86
7.4.220.0120.00616.82
7.4.210.0070.00716.83
7.4.200.0030.00316.80
7.4.190.0070.00017.05
7.4.160.0000.02116.78
7.4.150.0040.01517.40
7.4.140.0110.00517.86
7.4.130.0190.01116.91
7.4.120.0090.00816.88
7.4.110.0130.00316.87
7.4.100.0100.00716.72
7.4.90.0090.00916.80
7.4.80.0110.00719.39
7.4.70.0140.00316.77
7.4.60.0080.00816.60
7.4.50.0040.00416.78
7.4.40.0100.00322.77
7.4.30.0040.01216.75
7.4.00.0090.00815.01
7.3.330.0000.00513.64
7.3.320.0030.00213.66
7.3.310.0000.00716.45
7.3.300.0000.00716.66
7.3.290.0100.00316.57
7.3.280.0080.00916.63
7.3.270.0060.01217.40
7.3.260.0140.00418.24
7.3.250.0100.00816.92
7.3.240.0090.00916.73
7.3.230.0030.01416.85
7.3.210.0030.01416.80
7.3.200.0070.01619.39
7.3.190.0110.01116.76
7.3.180.0100.00616.84
7.3.170.0070.01016.78
7.3.160.0200.00016.84
7.3.120.0060.00615.05
7.3.110.0070.01114.86
7.3.100.0060.00915.16
7.3.90.0100.00315.30
7.3.80.0030.00715.35
7.3.70.0040.01115.32
7.3.60.0130.00615.00
7.3.50.0070.01315.11
7.3.40.0070.00715.13
7.3.30.0070.00715.18
7.3.20.0100.00317.04
7.3.10.0030.00917.07
7.3.00.0070.01016.95
7.2.330.0070.01116.84
7.2.320.0100.01016.76
7.2.310.0140.00316.99
7.2.300.0140.00316.79
7.2.290.0030.01417.13
7.2.250.0100.01015.55
7.2.240.0080.01215.16
7.2.230.0120.00015.36
7.2.220.0090.00015.21
7.2.210.0000.01615.54
7.2.200.0120.00315.43
7.2.190.0070.00715.07
7.2.180.0090.00615.47
7.2.170.0040.01114.98
7.1.330.0110.00316.25
7.1.320.0070.00416.09
7.1.310.0040.01416.09
7.1.300.0100.00716.03
7.1.290.0040.01116.09
7.1.280.0060.00915.96
7.1.270.0070.00715.86
7.1.260.0030.01016.04
7.1.200.0040.01116.02
7.1.70.0090.00517.26
7.1.60.0120.00919.17
7.1.50.0120.00916.95
7.1.00.0000.03722.29
7.0.200.0000.00816.97
7.0.140.0100.07022.01
7.0.90.0030.05319.95
7.0.80.0170.07720.03
7.0.70.0200.07320.01
7.0.60.0030.05019.96
7.0.50.0030.08720.38
7.0.40.0100.07720.14
7.0.30.0100.06720.05
7.0.20.0070.08020.04
7.0.10.0070.08720.10
7.0.00.0130.07020.17
5.6.280.0030.07321.14
5.6.240.0170.07320.61
5.6.230.0100.08020.70
5.6.220.0170.07720.72
5.6.210.0170.03720.47
5.6.200.0200.07721.03
5.6.190.0100.08021.19
5.6.180.0070.08321.15
5.6.170.0070.08721.07
5.6.160.0170.08021.15
5.6.150.0170.05021.09
5.6.140.0070.07721.15
5.6.130.0070.08321.05
5.6.120.0070.04320.97
5.6.110.0100.08021.09
5.6.100.0070.07021.04
5.6.90.0070.04321.03
5.6.80.0100.03720.45
5.6.70.0100.04320.43
5.6.60.0070.04020.50
5.6.50.0070.08020.57
5.6.40.0130.09320.48
5.6.30.0100.03720.39
5.6.20.0100.07320.41
5.6.10.0170.07020.50
5.6.00.0070.07720.29
5.5.380.0070.04320.41
5.5.370.0070.04720.36
5.5.360.0130.04720.36
5.5.350.0030.04720.48
5.5.340.0030.08320.80
5.5.330.0130.08020.86
5.5.320.0070.06720.91
5.5.310.0200.06720.91
5.5.300.0130.08020.78
5.5.290.0170.06020.91
5.5.280.0130.07320.75
5.5.270.0100.08020.92
5.5.260.0130.06020.87
5.5.250.0070.07320.63
5.5.240.0100.07720.04
5.5.230.0070.05020.23
5.5.220.0070.04320.04
5.5.210.0130.07320.11
5.5.200.0130.06720.25
5.5.190.0170.07720.25
5.5.180.0100.08020.29
5.5.160.0100.07320.26
5.5.150.0070.07320.20
5.5.140.0030.08020.16
5.5.130.0130.07320.16
5.5.120.0070.07320.01
5.5.110.0070.07320.16
5.5.100.0070.06020.12
5.5.90.0070.08320.09
5.5.80.0170.07020.16
5.5.70.0030.08720.11
5.5.60.0030.08320.16
5.5.50.0100.06020.13
5.5.40.0070.04020.12
5.5.30.0130.07719.98
5.5.20.0170.06320.11
5.5.10.0130.05720.05
5.5.00.0070.08320.11
5.4.450.0070.07319.46
5.4.440.0100.07019.46
5.4.430.0030.04319.48
5.4.420.0000.08719.46
5.4.410.0070.07719.37
5.4.400.0100.05019.24
5.4.390.0070.07319.05
5.4.380.0070.09018.90
5.4.370.0000.04318.95
5.4.360.0070.08019.05
5.4.350.0130.04319.25
5.4.340.0070.08019.12
5.4.320.0100.07319.05
5.4.310.0030.08319.21
5.4.300.0100.06719.22
5.4.290.0170.07318.84
5.4.280.0100.07319.09
5.4.270.0100.06019.18
5.4.260.0170.07019.05
5.4.250.0200.07019.04
5.4.240.0200.05719.18
5.4.230.0100.07319.08
5.4.220.0030.05019.04
5.4.210.0030.07719.08
5.4.200.0070.03719.20
5.4.190.0070.08318.86
5.4.180.0100.07019.11
5.4.170.0130.07719.04
5.4.160.0030.06019.13
5.4.150.0270.07019.16
5.4.140.0030.07716.23
5.4.130.0070.06016.45
5.4.120.0000.04716.53
5.4.110.0000.04316.52
5.4.100.0130.02716.52
5.4.90.0030.03716.48
5.4.80.0030.04016.54
5.4.70.0030.03716.43
5.4.60.0070.04016.48
5.4.50.0100.03316.31
5.4.40.0030.04016.45
5.4.30.0030.04716.30
5.4.20.0130.07716.45
5.4.10.0100.07016.47
5.4.00.0030.03315.97
5.3.290.0100.07714.82
5.3.280.0070.05014.82
5.3.270.0070.06314.82
5.3.260.0070.07314.82
5.3.250.0130.04714.82
5.3.240.0100.06714.82
5.3.230.0130.03314.82
5.3.220.0070.04014.82
5.3.210.0030.04014.82
5.3.200.0100.03314.82
5.3.190.0030.05014.82
5.3.180.0030.03714.82
5.3.170.0030.03714.82
5.3.160.0070.04014.82
5.3.150.0000.04714.82
5.3.140.0030.05314.82
5.3.130.0030.03314.82
5.3.120.0100.04714.82
5.3.110.0000.04314.82
5.3.100.0030.04314.82
5.3.90.0000.03714.82
5.3.80.0030.03714.82
5.3.70.0000.04014.82
5.3.60.0100.07014.82
5.3.50.0070.05714.82
5.3.40.0030.03014.82
5.3.30.0030.04014.82
5.3.20.0070.05014.82
5.3.10.0100.06314.82
5.3.00.0030.05014.82
5.2.170.0000.04014.82
5.2.160.0000.02714.82
5.2.150.0070.04714.82
5.2.140.0070.02314.82
5.2.130.0030.03314.82
5.2.120.0030.03314.82
5.2.110.0000.03014.82
5.2.100.0000.03014.82
5.2.90.0000.03314.82
5.2.80.0030.03014.82
5.2.70.0000.03314.82
5.2.60.0000.03314.82
5.2.50.0100.02314.82
5.2.40.0030.02714.82
5.2.30.0030.05014.82
5.2.20.0030.02714.82
5.2.10.0030.03014.82
5.2.00.0000.03314.82
5.1.60.0000.02314.82
5.1.50.0030.03314.82
5.1.40.0100.01314.82
5.1.30.0030.02714.82
5.1.20.0030.02714.82
5.1.10.0030.02314.82
5.1.00.0000.02714.82
5.0.50.0030.02014.82
5.0.40.0000.02014.82
5.0.30.0030.03314.82
5.0.20.0000.04314.82
5.0.10.0030.01714.82
5.0.00.0000.02714.82
4.4.90.0000.01714.82
4.4.80.0030.02014.82
4.4.70.0000.01714.82
4.4.60.0030.01314.82
4.4.50.0030.01714.82
4.4.40.0000.02314.82
4.4.30.0000.01714.82
4.4.20.0000.01714.82
4.4.10.0000.01714.82
4.4.00.0000.02314.82
4.3.110.0030.01314.82
4.3.100.0030.01314.82
4.3.90.0000.02314.82
4.3.80.0000.03014.82
4.3.70.0000.01714.82
4.3.60.0000.01314.82
4.3.50.0030.01314.82
4.3.40.0000.02714.82
4.3.30.0030.01314.82
4.3.20.0000.01714.82
4.3.10.0030.02014.82
4.3.00.0000.01314.82

preferences:
59.53 ms | 400 KiB | 5 Q