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]); $tempMonth = date('n', strtotime('-1 year', $second)) - 1; for($n = 0; $n < 12; $n++) { var_dump($temp); 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.60.0150.00618.81
8.3.50.0090.01121.27
8.3.40.0120.00318.99
8.3.30.0030.01020.47
8.3.20.0000.00820.32
8.3.10.0080.00022.07
8.3.00.0000.00822.57
8.2.180.0110.00616.61
8.2.170.0000.01522.96
8.2.160.0030.01022.21
8.2.150.0080.00024.18
8.2.140.0000.00724.66
8.2.130.0000.00726.16
8.2.120.0100.00619.61
8.2.110.0000.01020.34
8.2.100.0070.00419.82
8.2.90.0040.00419.42
8.2.80.0000.00819.59
8.2.70.0040.00417.86
8.2.60.0040.00418.18
8.2.50.0050.00318.07
8.2.40.0040.00418.27
8.2.30.0000.00719.47
8.2.20.0030.00518.05
8.2.10.0000.00918.04
8.2.00.0000.00818.21
8.1.280.0110.00425.92
8.1.270.0040.00423.99
8.1.260.0090.00626.35
8.1.250.0080.00028.09
8.1.240.0060.00323.96
8.1.230.0070.00421.04
8.1.220.0050.00317.74
8.1.210.0050.00318.77
8.1.200.0030.00617.60
8.1.190.0040.00417.65
8.1.180.0060.00318.10
8.1.170.0030.00518.74
8.1.160.0040.00419.18
8.1.150.0030.00618.91
8.1.140.0000.00817.72
8.1.130.0050.00217.79
8.1.120.0070.00017.88
8.1.110.0040.00417.75
8.1.100.0000.00817.72
8.1.90.0040.00417.84
8.1.80.0000.00717.83
8.1.70.0030.00517.84
8.1.60.0000.00817.92
8.1.50.0050.00317.82
8.1.40.0040.00417.83
8.1.30.0040.00417.88
8.1.20.0000.00817.92
8.1.10.0000.00817.85
8.1.00.0030.00617.86
8.0.300.0000.00718.77
8.0.290.0080.00017.30
8.0.280.0070.00018.71
8.0.270.0030.00317.54
8.0.260.0040.00417.24
8.0.250.0030.00317.36
8.0.240.0000.00917.34
8.0.230.0030.00617.37
8.0.220.0080.00017.29
8.0.210.0030.00317.31
8.0.200.0040.00417.39
8.0.190.0030.00617.33
8.0.180.0000.00717.37
8.0.170.0090.00017.32
8.0.160.0060.00317.23
8.0.150.0060.00317.26
8.0.140.0040.00417.33
8.0.130.0000.00613.64
8.0.120.0040.00417.18
8.0.110.0000.00717.23
8.0.100.0000.00717.34
8.0.90.0020.00517.37
8.0.80.0100.01017.27
8.0.70.0050.00217.14
8.0.60.0040.00417.29
8.0.50.0050.00217.23
8.0.30.0100.01017.50
8.0.20.0160.00517.43
8.0.10.0000.00717.46
8.0.00.0060.01217.19
7.4.330.0000.00516.78
7.4.320.0030.00316.81
7.4.300.0030.00316.65
7.4.290.0070.00016.88
7.4.280.0000.00816.79
7.4.270.0000.00816.89
7.4.260.0000.00513.50
7.4.250.0090.00016.81
7.4.240.0050.00316.87
7.4.230.0000.00816.74
7.4.220.0070.01116.83
7.4.210.0060.00816.82
7.4.200.0070.00016.70
7.4.190.0030.00316.98
7.4.160.0070.01116.94
7.4.150.0070.01417.40
7.4.140.0060.01617.86
7.4.130.0100.00816.79
7.4.120.0040.01216.87
7.4.110.0100.00716.80
7.4.100.0080.00816.91
7.4.90.0000.01716.82
7.4.80.0150.00319.39
7.4.70.0060.01216.94
7.4.60.0120.00616.77
7.4.50.0000.00917.02
7.4.40.0110.00722.77
7.4.30.0120.01217.04
7.4.00.0080.00815.31
7.3.330.0060.00013.51
7.3.320.0060.00013.47
7.3.310.0070.00016.50
7.3.300.0040.00416.66
7.3.290.0080.00616.67
7.3.280.0090.00816.64
7.3.270.0090.00917.40
7.3.260.0150.00418.24
7.3.250.0090.01216.83
7.3.240.0060.01116.67
7.3.230.0100.00716.91
7.3.210.0080.01216.73
7.3.200.0090.00919.39
7.3.190.0100.01316.71
7.3.180.0080.00816.82
7.3.170.0060.01016.93
7.3.160.0120.00416.80
7.3.120.0030.00815.04
7.3.10.0110.00316.90
7.3.00.0060.00317.09
7.2.330.0060.01216.90
7.2.320.0090.00817.29
7.2.310.0170.00717.12
7.2.300.0090.00916.76
7.2.290.0150.00316.87
7.2.130.0060.00617.16
7.2.120.0060.00916.89
7.2.110.0100.00317.12
7.2.100.0040.00817.32
7.2.90.0100.00317.24
7.2.80.0030.01316.93
7.2.70.0040.00717.12
7.2.60.0100.00717.16
7.2.50.0100.00317.35
7.2.40.0070.00717.18
7.2.30.0070.00717.32
7.2.20.0090.00616.98
7.2.10.0080.00317.23
7.2.00.0050.01118.16
7.1.250.0070.00315.99
7.1.100.0090.00618.40
7.1.70.0000.01417.43
7.1.60.0070.01719.17
7.1.50.0060.01917.27
7.1.00.0000.03722.50
7.0.200.0000.00717.14
7.0.140.0030.07321.95
7.0.100.0030.08719.99
7.0.90.0000.09319.89
7.0.80.0030.07019.90
7.0.70.0000.04720.05
7.0.60.0030.08319.81
7.0.50.0070.04320.24
7.0.40.0070.05020.14
7.0.30.0070.08020.13
7.0.20.0030.04720.18
7.0.10.0100.05020.04
7.0.00.0000.08720.04
5.6.280.0070.07021.14
5.6.250.0100.08020.84
5.6.240.0200.07320.71
5.6.230.0100.07720.59
5.6.220.0000.07720.75
5.6.210.0200.03020.51
5.6.200.0000.04721.02
5.6.190.0130.07320.96
5.6.180.0070.04021.06
5.6.170.0070.08321.03
5.6.160.0030.04720.97
5.6.150.0100.06020.98
5.6.140.0130.07321.07
5.6.130.0130.08321.09
5.6.120.0030.07721.03
5.6.110.0030.05021.03
5.6.100.0070.06321.14
5.6.90.0130.04020.96
5.6.80.0070.04320.51
5.6.70.0070.08020.41
5.6.60.0170.06720.44
5.6.50.0070.07720.37
5.6.40.0070.08720.54
5.6.30.0100.07720.49
5.6.20.0000.06020.45
5.6.10.0100.03720.45
5.6.00.0070.04020.38
5.5.380.0100.04320.39
5.5.370.0130.07720.38
5.5.360.0130.03720.55
5.5.350.0100.04020.46
5.5.340.0030.07720.95
5.5.330.0130.04320.96
5.5.320.0000.06320.95
5.5.310.0170.04720.82
5.5.300.0100.06020.84
5.5.290.0000.05020.82
5.5.280.0000.05720.90
5.5.270.0030.07720.94
5.5.260.0070.08020.90
5.5.250.0000.07720.72
5.5.240.0030.07320.20
5.5.230.0070.08020.26
5.5.220.0070.08320.15
5.5.210.0100.07320.15
5.5.200.0100.06320.15
5.5.190.0070.04320.27
5.5.180.0070.08320.18
5.5.160.0130.03320.16
5.5.150.0030.04020.23
5.5.140.0100.03720.14
5.5.130.0030.04020.01
5.5.120.0000.04720.29
5.5.110.0030.03720.22
5.5.100.0070.04719.97
5.5.90.0070.03719.96
5.5.80.0030.04020.03
5.5.70.0070.03720.08
5.5.60.0070.03720.08
5.5.50.0030.04020.08
5.5.40.0100.05320.11
5.5.30.0000.05320.10
5.5.20.0000.06020.07
5.5.10.0030.04320.07
5.5.00.0070.04020.14
5.4.450.0070.08319.45
5.4.440.0000.08019.50
5.4.430.0030.05019.27
5.4.420.0000.09319.20
5.4.410.0000.06719.34
5.4.400.0070.06319.20
5.4.390.0030.08318.85
5.4.380.0100.07318.88
5.4.370.0100.03319.14
5.4.360.0200.06719.04
5.4.350.0130.07019.09
5.4.340.0070.07319.05
5.4.320.0070.07719.04
5.4.310.0070.04019.02
5.4.300.0100.03019.04
5.4.290.0070.03319.09
5.4.280.0000.04019.12
5.4.270.0100.03019.23
5.4.260.0100.03019.04
5.4.250.0030.03019.17
5.4.240.0030.03319.03
5.4.230.0000.04019.02
5.4.220.0070.03019.23
5.4.210.0070.03719.11
5.4.200.0000.04319.18
5.4.190.0030.04019.02
5.4.180.0070.07018.84
5.4.170.0000.03718.93
5.4.160.0000.04019.02
5.4.150.0070.03319.03
5.4.140.0030.03716.52
5.4.130.0030.03016.51
5.4.120.0030.04316.39
5.4.110.0070.06316.45
5.4.100.0000.03316.54
5.4.90.0100.03016.55
5.4.80.0000.03716.43
5.4.70.0000.04716.55
5.4.60.0000.04016.40
5.4.50.0030.03316.43
5.4.40.0000.04316.46
5.4.30.0070.02716.33
5.4.20.0000.03716.25
5.4.10.0030.03316.45
5.4.00.0030.03015.90
5.3.290.0070.05014.70
5.3.280.0000.05314.71
5.3.270.0030.05714.62
5.3.260.0100.03314.66
5.3.250.0070.03314.76
5.3.240.0000.04014.55
5.3.230.0030.04014.54
5.3.220.0130.03014.57
5.3.210.0030.07314.53
5.3.200.0070.03314.55
5.3.190.0030.03314.62
5.3.180.0000.04014.52
5.3.170.0130.02714.52
5.3.160.0070.03314.70
5.3.150.0030.03714.53
5.3.140.0030.04014.54
5.3.130.0030.03714.57
5.3.120.0070.03314.69
5.3.110.0000.04014.56
5.3.100.0100.04014.18
5.3.90.0030.03714.09
5.3.80.0000.06313.96
5.3.70.0070.03313.97
5.3.60.0070.03313.91
5.3.50.0070.03313.98
5.3.40.0000.04714.06
5.3.30.0100.05314.03
5.3.20.0000.03313.85
5.3.10.0030.03713.70
5.3.00.0030.03713.58
5.2.170.0070.04311.09
5.2.160.0070.02011.03
5.2.150.0000.03311.15
5.2.140.0000.04711.22
5.2.130.0030.06011.20
5.2.120.0000.02711.04
5.2.110.0000.03011.24
5.2.100.0070.06311.18
5.2.90.0070.03011.19
5.2.80.0030.03011.15
5.2.70.0000.06011.17
5.2.60.0030.05311.21
5.2.50.0030.06010.96
5.2.40.0030.06311.08
5.2.30.0030.06010.93
5.2.20.0030.05710.98
5.2.10.0000.03310.81
5.2.00.0100.02310.75
5.1.60.0100.02310.31
5.1.50.0070.04310.31
5.1.40.0070.04010.31
5.1.30.0000.03310.33
5.1.20.0100.04710.31
5.1.10.0100.02310.31
5.1.00.0030.03010.31
5.0.50.0000.04310.31
5.0.40.0000.02310.31
5.0.30.0100.04710.31
5.0.20.0030.03310.31
5.0.10.0070.02710.31
5.0.00.0030.03710.31
4.4.90.0030.03010.31
4.4.80.0030.03010.31
4.4.70.0000.02710.31
4.4.60.0000.03310.31
4.4.50.0030.01310.31
4.4.40.0030.05010.31
4.4.30.0000.03010.31
4.4.20.0030.01710.31
4.4.10.0030.03010.31
4.4.00.0000.03010.31
4.3.110.0030.01310.31
4.3.100.0070.03010.31
4.3.90.0000.02010.31
4.3.80.0070.03010.31
4.3.70.0000.02010.31
4.3.60.0000.03010.31
4.3.50.0000.01710.31
4.3.40.0000.04010.31
4.3.30.0030.02310.31
4.3.20.0000.03010.31
4.3.10.0000.03710.31
4.3.00.0000.03010.31

preferences:
47.62 ms | 401 KiB | 5 Q