3v4l.org

run code in 300+ PHP versions simultaneously
<?php date_default_timezone_set('UTC'); function dateDiff($startdate, $enddate) { $first = $startdate < $enddate ? $startdate : $enddate; $second = $startdate < $enddate ? $enddate : $startdate; $inbetween = $second - $first; $firsttemp = $first; $months = 0; $days = 0; while(TRUE) { if($firsttemp + 86400* date('t', $firsttemp) <= $second) { $months += 1; $firsttemp += 86400 * date('t', $firsttemp); } else { $days = floor(($second - $firsttemp) / 86400); break; } } $years = floor($months / 12); $months = $months % 12; $hours = floor($inbetween / 60 / 60 % 24); $minutes = floor($inbetween / 60 % 60); $seconds = $inbetween % 60; $dateObj = new stdClass(); $dateObj->years = $years; $dateObj->months = $months; $dateObj->days = $days; $dateObj->hours = $hours; $dateObj->minutes = $minutes; $dateObj->seconds = $seconds; $dateObj->dayyyy = floor($inbetween / 60 / 60 / 24); return $dateObj; } $str1 = "1970-01-01 + 21 sec"; $str2 = "2009-01-01 + 54612 sec"; $tempdate1 = $str1; $date1 = new DateTime($str1); $n = 0; $date2 = new DateTime($str2); $interval = $date1->diff($date2); var_dump($interval); $string1 = "(" . $interval->days . ") difference " . $interval->y . " years, " . $interval->m . " months, " . $interval->d . " days"; $mydate = dateDiff(strtotime($str1), strtotime($str2)); $string2 = "(" . $mydate->dayyyy . ") difference " . $mydate->years . " years, " . $mydate->months . " months, " . $mydate->days . " days, " . $mydate->hours . " hours, " . $mydate->minutes . " minutes, and " . $mydate->seconds . " seconds"; if($string1 !== $string2) { echo "<span style=\"color:red;\">", $string1, " - ", $string2, "</span><br />"; // This will never run } else { echo "<span style=\"color:green;\">", $string1, " - ", $string2, "</span><br />"; } $n++; $tempdate1 = $str1 . " +" . $n . " days";

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.0.110.0050.00317.03
8.0.100.0030.00617.13
8.0.90.0000.00817.19
8.0.80.0030.01317.18
8.0.70.0030.00517.17
8.0.60.0030.00617.26
8.0.50.0030.00717.17
8.0.30.0070.01117.29
8.0.20.0110.00917.18
8.0.10.0000.00817.42
8.0.00.0090.01417.06
7.4.240.0000.00716.72
7.4.230.0000.00716.60
7.4.220.0140.01716.91
7.4.210.0070.01016.71
7.4.200.0070.00016.84
7.4.190.0000.00816.98
7.4.160.0070.01016.83
7.4.150.0090.01016.68
7.4.140.0150.01217.86
7.4.130.0120.00616.64
7.4.120.0070.01316.72
7.4.110.0210.00316.69
7.4.100.0130.00516.70
7.4.90.0100.01016.75
7.4.80.0110.00619.39
7.4.70.0090.01016.80
7.4.60.0090.00916.84
7.4.50.0000.00716.54
7.4.40.0080.00616.73
7.4.30.0060.01116.66
7.4.00.0030.01315.25
7.3.300.0030.00516.75
7.3.290.0060.01116.65
7.3.280.0110.01216.70
7.3.270.0120.00616.77
7.3.260.0080.01116.75
7.3.240.0040.01416.69
7.3.230.0160.01016.70
7.3.210.0110.00716.62
7.3.200.0060.01216.66
7.3.190.0050.01316.68
7.3.180.0080.00816.87
7.3.170.0130.00916.71
7.3.160.0110.00716.59
7.3.120.0090.00615.13
7.2.330.0110.00816.85
7.2.320.0130.00617.05
7.2.310.0190.00617.03
7.2.300.0110.00617.13
7.2.290.0120.00816.78
7.2.60.0810.00615.29
7.2.00.0000.01219.71
7.1.200.0060.00916.03
7.1.100.0100.00718.43
7.1.70.0000.00717.52
7.1.60.0110.01119.25
7.1.50.0100.01417.13
7.1.00.0000.03722.31
7.0.200.0000.01016.59
7.0.140.0030.07022.01
7.0.120.0070.07321.96
7.0.100.0130.05020.21
7.0.90.0100.08019.94
7.0.80.0070.07719.97
7.0.70.0130.08019.97
7.0.60.0130.07319.90
7.0.50.0170.07320.18
7.0.40.0100.08320.15
7.0.30.0030.05720.13
7.0.20.0130.04720.11
7.0.10.0030.08020.14
7.0.00.0030.06020.07
5.6.280.0070.07320.93
5.6.250.0070.08320.66
5.6.240.0130.08320.67
5.6.230.0000.04720.71
5.6.220.0070.08320.73
5.6.210.0170.08020.79
5.6.200.0070.08320.96
5.6.190.0070.08321.05
5.6.180.0130.06721.20
5.6.170.0070.07721.03
5.6.160.0100.08021.10
5.6.150.0030.08721.04
5.6.140.0230.06320.96
5.6.130.0100.08321.03
5.6.120.0100.07321.09
5.6.110.0130.05321.15
5.6.100.0070.06021.05
5.6.90.0100.07721.07
5.6.80.0100.08320.36
5.6.70.0070.06320.48
5.6.60.0130.04320.56
5.6.50.0000.08720.54
5.6.40.0200.03320.52
5.6.30.0170.07320.41
5.6.20.0030.08320.30
5.6.10.0100.04720.39
5.6.00.0000.05020.44
5.5.380.0200.06320.39
5.5.370.0000.04720.38
5.5.360.0070.04720.43
5.5.350.0130.08020.39
5.5.340.0130.07320.80
5.5.330.0200.06320.86
5.5.320.0130.03320.90
5.5.310.0100.08020.91
5.5.300.0070.06020.91
5.5.290.0070.11020.91
5.5.280.0100.04320.80
5.5.270.0070.08720.88
5.5.260.0130.08320.88
5.5.250.0130.08320.70
5.5.240.0270.06320.13
5.5.230.0030.04720.20
5.5.220.0100.07320.29
5.5.210.0130.07020.17
5.5.200.0100.04320.30
5.5.190.0000.08320.14
5.5.180.0100.05720.10
5.5.160.0100.07020.29
5.5.150.0100.07720.29
5.5.140.0130.05020.17
5.5.130.0100.07720.24
5.5.120.0100.07320.24
5.5.110.0130.06720.09
5.5.100.0070.05720.19
5.5.90.0100.07720.09
5.5.80.0130.07720.02
5.5.70.0070.07320.10
5.5.60.0030.04020.14
5.5.50.0130.06320.08
5.5.40.0100.05720.10
5.5.30.0200.07019.95
5.5.20.0130.07020.02
5.5.10.0130.04020.14
5.5.00.0070.05020.04
5.4.450.0070.04719.23
5.4.440.0070.08019.37
5.4.430.0070.05319.50
5.4.420.0100.07719.46
5.4.410.0100.04019.10
5.4.400.0100.06019.04
5.4.390.0030.04318.84
5.4.380.0200.05719.09
5.4.370.0030.07319.23
5.4.360.0100.05318.90
5.4.350.0200.07019.12
5.4.340.0130.07018.88
5.4.320.0100.06319.12
5.4.310.0000.07019.05
5.4.300.0070.08318.90
5.4.290.0100.06318.85
5.4.280.0070.08018.85
5.4.270.0070.08019.10
5.4.260.0030.04719.04
5.4.250.0030.04318.93
5.4.240.0030.08019.00
5.4.230.0070.06719.04
5.4.220.0070.07019.12
5.4.210.0070.06719.15
5.4.200.0030.05019.12
5.4.190.0030.04019.02
5.4.180.0100.07719.15
5.4.170.0130.07719.04
5.4.160.0070.07319.12
5.4.150.0100.06318.86
5.4.140.0100.07316.47
5.4.130.0030.05016.46
5.4.120.0030.08016.53
5.4.110.0100.07016.40
5.4.100.0030.07316.49
5.4.90.0030.07716.34
5.4.80.0170.07016.36
5.4.70.0100.06716.55
5.4.60.0100.06316.41
5.4.50.0070.07316.31
5.4.40.0000.04716.46
5.4.30.0070.05316.46
5.4.20.0070.04716.41
5.4.10.0130.04316.33
5.4.00.0200.03015.80
5.3.290.0070.04014.67
5.3.280.0030.05314.76
5.3.270.0070.07014.65
5.3.260.0100.04314.76
5.3.250.0100.07314.73
5.3.240.0130.06714.62
5.3.230.0070.06014.56
5.3.220.0100.03714.59
5.3.210.0130.07714.66
5.3.200.0100.06314.62
5.3.190.0100.08014.53
5.3.180.0070.07314.75
5.3.170.0070.07314.66
5.3.160.0070.05014.71
5.3.150.0100.04014.64
5.3.140.0070.04314.71
5.3.130.0130.04014.67
5.3.120.0130.06314.58
5.3.110.0100.04314.55
5.3.100.0030.04314.03
5.3.90.0070.04314.14
5.3.80.0030.05014.11
5.3.70.0130.05714.09
5.3.60.0070.04314.14
5.3.50.0100.05013.88
5.3.40.0100.05713.95
5.3.30.0070.07313.99
5.3.20.0030.07013.77
5.3.10.0070.06313.82
5.3.00.0030.07013.55
5.2.170.0030.05011.24
5.2.160.0030.06311.22
5.2.150.0170.05711.19
5.2.140.0030.05311.19
5.2.130.0000.05311.05
5.2.120.0070.04711.27
5.2.110.0030.06311.20
5.2.100.0030.06311.18
5.2.90.0100.05311.25
5.2.80.0000.06711.01
5.2.70.0030.07011.23
5.2.60.0070.06311.11
5.2.50.0070.03311.11
5.2.40.0030.05011.02
5.2.30.0030.06711.05
5.2.20.0100.05310.98
5.2.10.0070.05711.03
5.2.00.0100.03710.61
5.1.60.0070.05010.02
5.1.50.0000.0579.91
5.1.40.0100.0379.99
5.1.30.0070.05710.28
5.1.20.0030.04010.32
5.1.10.0170.04310.16
5.1.00.0030.05710.21
5.0.50.0000.0509.14
5.0.40.0030.0439.14
5.0.30.0030.0439.14
5.0.20.0070.0409.14
5.0.10.0030.0379.14
5.0.00.0030.0639.14
4.4.90.0030.0339.14
4.4.80.0030.0209.14
4.4.70.0030.0279.14
4.4.60.0030.0379.14
4.4.50.0070.0309.14
4.4.40.0000.0309.14
4.4.30.0030.0309.14
4.4.20.0030.0339.14
4.4.10.0070.0309.14
4.4.00.0100.0509.14
4.3.110.0030.0239.14
4.3.100.0030.0279.14
4.3.90.0030.0239.14
4.3.80.0000.0309.14
4.3.70.0000.0279.14
4.3.60.0030.0209.14
4.3.50.0030.0379.14
4.3.40.0000.0539.14
4.3.30.0030.0309.14
4.3.20.0030.0309.14
4.3.10.0000.0409.14
4.3.00.0070.0339.14

preferences:
35.57 ms | 401 KiB | 5 Q