3v4l.org

run code in 300+ PHP versions simultaneously
<?php function dateDiff($startdate, $enddate) { $first = $startdate < $enddate ? $startdate : $enddate; $second = $startdate < $enddate ? $enddate : $startdate; $inbetween = $second - $first; $i[0] = 60; $i[1] = 24; $i[2] = array(31, (date('L', strtotime('-1 year', $second)) ? 28 : 29), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); $months = 0; $days = 0; $tempDays = $inbetween / $i[0] / $i[0] / $i[1] % 365.25; var_dump($tempDays); $tempMonth = date('n', strtotime('-1 year', $second)) - 1; for($n = 0; $n < 12; $n++) { if($tempDays >= $i[2][$tempMonth]) { $months += 1; $tempDays -= $i[2][$tempMonth]; } else { $days = round($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 = dateDiff(1388534400, 1483146061); echo $mydate->years, " years, ", $mydate->months, " months, ", $mydate->days, " days, ", $mydate->hours, " hours, ", $mydate->minutes, " minutes, and ", $mydate->seconds, " seconds";

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.0140.00418.68
8.3.50.0250.00721.26
8.3.40.0110.00419.00
8.3.30.0030.01020.17
8.3.20.0080.00020.38
8.3.10.0040.00421.95
8.3.00.0040.00422.44
8.2.180.0140.00717.13
8.2.170.0120.00322.96
8.2.160.0090.00622.26
8.2.150.0050.00324.18
8.2.140.0090.00024.66
8.2.130.0040.00426.16
8.2.120.0060.00320.82
8.2.110.0110.00022.08
8.2.100.0060.00619.89
8.2.90.0040.00419.39
8.2.80.0050.00319.39
8.2.70.0030.00617.88
8.2.60.0000.00818.02
8.2.50.0060.00318.07
8.2.40.0040.00418.40
8.2.30.0040.00419.68
8.2.20.0000.00818.18
8.2.10.0080.00018.03
8.2.00.0000.00818.13
8.1.280.0070.01425.92
8.1.270.0040.00423.99
8.1.260.0080.00026.35
8.1.250.0030.00628.09
8.1.240.0060.00323.94
8.1.230.0070.00420.96
8.1.220.0030.00617.91
8.1.210.0000.00818.77
8.1.200.0030.00617.60
8.1.190.0040.00417.54
8.1.180.0050.00518.10
8.1.170.0080.00018.94
8.1.160.0000.00719.04
8.1.150.0040.00418.94
8.1.140.0050.00217.80
8.1.130.0000.00718.09
8.1.120.0040.00417.77
8.1.110.0070.00017.70
8.1.100.0040.00417.65
8.1.90.0040.00417.75
8.1.80.0040.00417.65
8.1.70.0000.00717.67
8.1.60.0000.00917.75
8.1.50.0040.00417.75
8.1.40.0040.00417.70
8.1.30.0030.00517.85
8.1.20.0030.00517.77
8.1.10.0030.00617.78
8.1.00.0050.00317.80
8.0.300.0080.00018.77
8.0.290.0000.00717.18
8.0.280.0000.00718.64
8.0.270.0030.00617.45
8.0.260.0030.00317.20
8.0.250.0000.00717.34
8.0.240.0060.00317.36
8.0.230.0000.00717.20
8.0.220.0030.00317.25
8.0.210.0030.00317.18
8.0.200.0030.00317.33
8.0.190.0030.00617.39
8.0.180.0030.00517.23
8.0.170.0030.00617.29
8.0.160.0040.00417.15
8.0.150.0040.00417.18
8.0.140.0080.00017.25
8.0.130.0000.00513.61
8.0.120.0040.00417.21
8.0.110.0080.00017.24
8.0.100.0080.00017.27
8.0.90.0040.00417.16
8.0.80.0070.00717.15
8.0.70.0030.00517.17
8.0.60.0030.00617.19
8.0.50.0040.00417.29
8.0.30.0130.00717.43
8.0.20.0090.00917.40
8.0.10.0050.00217.27
8.0.00.0070.01217.02
7.4.330.0050.00016.75
7.4.320.0000.00716.80
7.4.300.0000.00616.76
7.4.290.0030.00316.61
7.4.280.0030.00316.91
7.4.270.0030.00316.86
7.4.260.0000.00513.36
7.4.250.0030.00616.77
7.4.240.0030.00416.79
7.4.230.0000.00716.50
7.4.220.0000.02416.80
7.4.210.0050.01016.85
7.4.200.0030.00316.74
7.4.190.0070.00016.94
7.4.160.0120.00616.75
7.4.150.0190.00617.40
7.4.140.0130.00817.86
7.4.130.0140.00916.79
7.4.120.0060.01216.77
7.4.110.0000.01616.79
7.4.100.0090.01216.69
7.4.90.0120.00616.90
7.4.80.0090.00919.39
7.4.70.0060.01116.75
7.4.60.0060.00916.71
7.4.50.0000.00916.65
7.4.40.0040.01522.77
7.4.30.0130.00616.92
7.4.00.0030.01515.17
7.3.330.0030.00313.42
7.3.320.0030.00313.59
7.3.310.0000.00716.67
7.3.300.0070.00016.46
7.3.290.0030.01016.61
7.3.280.0070.00916.57
7.3.270.0060.01117.40
7.3.260.0090.00918.24
7.3.250.0090.00716.82
7.3.240.0030.01416.69
7.3.230.0100.00816.80
7.3.210.0120.00616.91
7.3.200.0110.01119.39
7.3.190.0070.00916.78
7.3.180.0000.01916.83
7.3.170.0100.00616.79
7.3.160.0140.00816.68
7.3.120.0100.00315.27
7.2.330.0150.00317.00
7.2.320.0130.01016.74
7.2.310.0060.01217.12
7.2.300.0170.00316.97
7.2.290.0130.00316.77
7.2.00.0090.00619.40
7.1.100.0070.00318.30
7.1.70.0030.00617.38
7.1.60.0130.01019.17
7.1.50.0030.02017.34
7.1.00.0030.07722.43
7.0.200.0040.00416.96
7.0.140.0030.07321.95
7.0.80.0700.05719.95
7.0.70.0570.04720.02
7.0.60.0430.06319.98
7.0.50.0570.04720.34
7.0.40.0000.06320.19
7.0.30.0130.08320.18
7.0.20.0170.07720.08
7.0.10.0030.05020.07
7.0.00.0000.05020.17
5.6.280.0000.07721.06
5.6.230.0130.08720.67
5.6.220.0070.05320.69
5.6.210.0100.08020.66
5.6.200.0100.08021.10
5.6.190.0100.07721.12
5.6.180.0030.08721.12
5.6.170.0030.09020.96
5.6.160.0030.09021.10
5.6.150.0130.05721.03
5.6.140.0030.08320.93
5.6.130.0170.06721.04
5.6.120.0200.05021.06
5.6.110.0100.08321.02
5.6.100.0100.06021.09
5.6.90.0100.08020.96
5.6.80.0100.07720.57
5.6.70.0130.05720.35
5.6.60.0030.08320.32
5.6.50.0030.05320.46
5.6.40.0030.05020.42
5.6.30.0030.04320.39
5.6.20.0030.08020.42
5.6.10.0200.06720.43
5.6.00.0200.04020.39
5.5.370.0100.07320.37
5.5.360.0230.07320.41
5.5.350.0070.08320.42
5.5.340.0000.06720.86
5.5.330.0030.05320.82
5.5.320.0030.04320.80
5.5.310.0030.07720.66
5.5.300.0130.05020.85
5.5.290.0100.08020.95
5.5.280.0100.08320.66
5.5.270.0130.08020.85
5.5.260.0000.05320.88
5.5.250.0100.04320.66
5.5.240.0230.06320.16
5.5.230.0030.08720.28
5.5.220.0100.08020.26
5.5.210.0070.04720.29
5.5.200.0030.05020.24
5.5.190.0130.06720.14
5.5.180.0100.07720.17
5.5.160.0070.07720.23
5.5.150.0000.08020.24
5.5.140.0130.06020.13
5.5.130.0130.07320.16
5.5.120.0130.06320.28
5.5.110.0130.06320.18
5.5.100.0030.04020.17
5.5.90.0170.07019.95
5.5.80.0000.08320.09
5.5.70.0000.08320.08
5.5.60.0070.08320.05
5.5.50.0130.07020.18
5.5.40.0070.08020.12
5.5.30.0130.07319.98
5.5.20.0100.07720.10
5.5.10.0100.08320.14
5.5.00.0170.06719.99
5.4.450.0030.04719.46
5.4.440.0170.06719.43
5.4.430.0100.07719.27
5.4.420.0130.07019.25
5.4.410.0070.04319.14
5.4.400.0130.06718.90
5.4.390.0200.05719.24
5.4.380.0070.04319.05
5.4.370.0070.07719.20
5.4.360.0100.05718.84
5.4.350.0100.08018.95
5.4.340.0230.05719.21
5.4.320.0100.07719.05
5.4.310.0100.07019.18
5.4.300.0100.04018.86
5.4.290.0070.07319.25
5.4.280.0100.04319.13
5.4.270.0070.06718.90
5.4.260.0070.03718.90
5.4.250.0100.06719.11
5.4.240.0030.06719.08
5.4.230.0070.07319.18
5.4.220.0030.07719.15
5.4.210.0230.06019.11
5.4.200.0000.05319.12
5.4.190.0070.05319.02
5.4.180.0070.08018.88
5.4.170.0070.08318.84
5.4.160.0100.04019.18
5.4.150.0000.05019.13
5.4.140.0100.07016.52
5.4.130.0030.07016.38
5.4.120.0100.06716.45
5.4.110.0030.07716.45
5.4.100.0130.06716.39
5.4.90.0030.04316.54
5.4.80.0170.06716.36
5.4.70.0000.05716.54
5.4.60.0100.03316.30
5.4.50.0070.07316.34
5.4.40.0100.07016.46
5.4.30.0100.07016.48
5.4.20.0070.06716.30
5.4.10.0100.03316.43
5.4.00.0030.07015.88
5.3.290.0100.04714.75
5.3.280.0130.06314.57
5.3.270.0070.05714.57
5.3.260.0030.04714.73
5.3.250.0070.07314.63
5.3.240.0070.04714.62
5.3.230.0070.07314.68
5.3.220.0130.07014.62
5.3.210.0000.05714.65
5.3.200.0070.03714.68
5.3.190.0100.07014.62
5.3.180.0130.07314.52
5.3.170.0130.06314.65
5.3.160.0000.08314.64
5.3.150.0070.03714.51
5.3.140.0100.07014.64
5.3.130.0070.05314.59
5.3.120.0170.07014.55
5.3.110.0100.04714.69
5.3.100.0200.05714.12
5.3.90.0070.07313.97
5.3.80.0030.05014.15
5.3.70.0030.07713.96
5.3.60.0030.05014.11
5.3.50.0030.04014.04
5.3.40.0030.07314.11
5.3.30.0030.06013.83
5.3.20.0030.06713.60
5.3.10.0100.07313.78
5.3.00.0030.07313.72
5.2.170.0030.06311.15
5.2.160.0030.06711.23
5.2.150.0070.05311.18
5.2.140.0030.05711.07
5.2.130.0070.06011.21
5.2.120.0070.04711.06
5.2.110.0070.05711.00
5.2.100.0070.03711.14
5.2.90.0070.05711.21
5.2.80.0070.06311.00
5.2.70.0100.06011.21
5.2.60.0070.04710.98
5.2.50.0100.06311.06
5.2.40.0100.05711.11
5.2.30.0130.04011.05
5.2.20.0100.05711.01
5.2.10.0000.04310.79
5.2.00.0170.03710.83
5.1.60.0030.05710.01
5.1.50.0030.06010.01
5.1.40.0100.04710.07
5.1.30.0030.04010.46
5.1.20.0000.04010.36
5.1.10.0000.06010.18
5.1.00.0000.0579.94
5.0.50.0070.0338.42
5.0.40.0030.0438.43
5.0.30.0000.0678.26
5.0.20.0070.0378.21
5.0.10.0030.0478.29
5.0.00.0000.0708.03
4.4.90.0000.0307.29
4.4.80.0000.0407.29
4.4.70.0030.0277.29
4.4.60.0000.0237.29
4.4.50.0030.0307.29
4.4.40.0070.0477.29
4.4.30.0030.0307.29
4.4.20.0030.0177.29
4.4.10.0070.0207.29
4.4.00.0100.0337.29
4.3.110.0000.0407.29
4.3.100.0030.0237.29
4.3.90.0100.0277.29
4.3.80.0070.0507.29
4.3.70.0030.0337.29
4.3.60.0000.0377.29
4.3.50.0070.0237.29
4.3.40.0000.0437.29
4.3.30.0030.0337.29
4.3.20.0000.0377.29
4.3.10.0100.0277.29
4.3.00.0000.0377.29

preferences:
36.91 ms | 401 KiB | 5 Q