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); $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.3.60.0060.01018.80
8.3.50.0140.00617.36
8.3.40.0070.00719.00
8.3.30.0150.00618.99
8.3.20.0040.00419.07
8.3.10.0000.00819.03
8.3.00.0080.00019.50
8.2.180.0100.00717.13
8.2.170.0080.00822.96
8.2.160.0140.00319.23
8.2.150.0030.00624.18
8.2.140.0060.00324.66
8.2.130.0050.00326.16
8.2.120.0040.00419.79
8.2.110.0030.00619.39
8.2.100.0090.00318.09
8.2.90.0060.00318.00
8.2.80.0080.00617.97
8.2.70.0030.00618.13
8.2.60.0000.00818.28
8.2.50.0030.00518.10
8.2.40.0030.00619.40
8.2.30.0040.00419.43
8.2.20.0090.00318.07
8.2.10.0000.00818.14
8.2.00.0000.00818.13
8.1.280.0040.01125.92
8.1.270.0000.00923.99
8.1.260.0000.00926.35
8.1.250.0000.00828.09
8.1.240.0070.00321.00
8.1.230.0060.00619.73
8.1.220.0060.00317.91
8.1.210.0030.00618.77
8.1.200.0030.01017.60
8.1.190.0030.00617.60
8.1.180.0030.00618.10
8.1.170.0050.00318.82
8.1.160.0040.00419.11
8.1.150.0000.00819.10
8.1.140.0080.00017.59
8.1.130.0040.00417.64
8.1.120.0000.00717.63
8.1.110.0050.00317.65
8.1.100.0040.00417.75
8.1.90.0050.00217.75
8.1.80.0040.00417.71
8.1.70.0000.00717.69
8.1.60.0000.00917.77
8.1.50.0030.00517.71
8.1.40.0070.00417.69
8.1.30.0030.00617.79
8.1.20.0080.00417.80
8.1.10.0030.00617.80
8.1.00.0080.00017.59
8.0.300.0040.00418.77
8.0.290.0030.00617.00
8.0.280.0050.00218.47
8.0.270.0070.00017.46
8.0.260.0050.00217.04
8.0.250.0020.00517.29
8.0.240.0030.00517.19
8.0.230.0090.00017.34
8.0.220.0040.00417.18
8.0.210.0040.00417.16
8.0.200.0030.00317.15
8.0.190.0030.00617.16
8.0.180.0030.00517.14
8.0.170.0080.00017.23
8.0.160.0040.00417.23
8.0.150.0000.00917.15
8.0.140.0000.00817.23
8.0.130.0000.00813.66
8.0.120.0030.00617.22
8.0.110.0000.00717.13
8.0.100.0040.00417.26
8.0.90.0000.00817.35
8.0.80.0150.00717.25
8.0.70.0040.00417.21
8.0.60.0000.00917.22
8.0.50.0060.00317.29
8.0.30.0100.01317.52
8.0.20.0060.01317.21
8.0.10.0000.00917.24
8.0.00.0110.01117.03
7.4.330.0000.00513.14
7.4.320.0000.00716.73
7.4.300.0030.00516.70
7.4.290.0080.00416.77
7.4.280.0030.00516.69
7.4.270.0070.00416.80
7.4.260.0000.00916.70
7.4.250.0030.00616.83
7.4.240.0000.00716.79
7.4.230.0000.00716.55
7.4.220.0170.00616.85
7.4.210.0090.00616.72
7.4.200.0000.00716.82
7.4.190.0060.00316.62
7.4.160.0170.00716.73
7.4.150.0140.00316.71
7.4.140.0060.01317.86
7.4.130.0110.00816.79
7.4.120.0100.00716.77
7.4.110.0230.01016.55
7.4.100.0180.00616.87
7.4.90.0030.01416.68
7.4.80.0140.00819.39
7.4.70.0070.01116.89
7.4.60.0000.01716.94
7.4.50.0030.00616.79
7.4.40.0030.01016.55
7.4.30.0040.01316.92
7.4.00.0090.00614.81
7.3.330.0000.00713.72
7.3.320.0060.00013.62
7.3.310.0090.00016.76
7.3.300.0000.00716.59
7.3.290.0060.01016.68
7.3.280.0070.01016.72
7.3.270.0030.01616.86
7.3.260.0280.03116.80
7.3.240.0150.00316.92
7.3.230.0130.00916.86
7.3.210.0090.00916.56
7.3.200.0130.00316.57
7.3.190.0080.00816.84
7.3.180.0080.00816.74
7.3.170.0160.00616.69
7.3.160.0100.00716.83
7.3.120.0030.00915.02
7.2.330.0100.01016.69
7.2.320.0160.00316.77
7.2.310.0140.00716.82
7.2.300.0060.01517.02
7.2.290.0060.01216.69
7.2.60.0040.01117.20
7.2.00.0030.01419.66
7.1.200.0080.00615.89
7.1.100.0030.00918.02
7.1.70.0040.00417.44
7.1.60.0210.00419.25
7.1.50.0060.01817.21
7.1.00.0000.04322.34
7.0.200.0080.00417.07
7.0.140.0000.07722.05
7.0.120.0030.06722.07
7.0.90.0030.05020.01
7.0.80.0030.04319.94
7.0.70.0130.08319.98
7.0.60.0070.04320.07
7.0.50.0230.04320.43
7.0.40.0070.08020.19
7.0.30.0100.04720.05
7.0.20.0030.05319.96
7.0.10.0100.08320.10
7.0.00.0030.05319.98
5.6.280.0030.07721.12
5.6.240.0230.02720.63
5.6.230.0100.08320.59
5.6.220.0000.07720.46
5.6.210.0030.04320.59
5.6.200.0100.07321.06
5.6.190.0100.04021.03
5.6.180.0170.07321.03
5.6.170.0030.04321.19
5.6.160.0100.06321.03
5.6.150.0070.08721.04
5.6.140.0170.06320.95
5.6.130.0100.06021.05
5.6.120.0100.06021.08
5.6.110.0000.04721.06
5.6.100.0000.08721.05
5.6.90.0170.07321.05
5.6.80.0130.04720.46
5.6.70.0000.05720.41
5.6.60.0100.06320.44
5.6.50.0030.08720.34
5.6.40.0100.05720.44
5.6.30.0100.04320.43
5.6.20.0030.04720.39
5.6.10.0100.07020.45
5.6.00.0230.07020.42
5.5.380.0130.06020.42
5.5.370.0070.04720.45
5.5.360.0100.04320.46
5.5.350.0030.04320.41
5.5.340.0170.06320.95
5.5.330.0030.04720.73
5.5.320.0100.07720.92
5.5.310.0100.07320.87
5.5.300.0070.04720.81
5.5.290.0130.07320.95
5.5.280.0100.04720.75
5.5.270.0030.05020.84
5.5.260.0030.05320.93
5.5.250.0170.06720.58
5.5.240.0100.06720.23
5.5.230.0070.07720.18
5.5.220.0100.07320.26
5.5.210.0070.08720.32
5.5.200.0030.05320.23
5.5.190.0030.06020.14
5.5.180.0000.05020.20
5.5.160.0100.04020.24
5.5.150.0130.03720.27
5.5.140.0070.03320.29
5.5.130.0070.06320.29
5.5.120.0100.07720.24
5.5.110.0130.07020.13
5.5.100.0030.08020.18
5.5.90.0030.04720.13
5.5.80.0030.08320.09
5.5.70.0030.05020.08
5.5.60.0200.07020.07
5.5.50.0100.03720.17
5.5.40.0070.07320.07
5.5.30.0030.05720.08
5.5.20.0070.04720.07
5.5.10.0170.06720.00
5.5.00.0000.09020.06
5.4.450.0000.05019.18
5.4.440.0000.07719.23
5.4.430.0100.05019.17
5.4.420.0070.04719.53
5.4.410.0070.07319.23
5.4.400.0000.05019.03
5.4.390.0130.07019.02
5.4.380.0030.05718.87
5.4.370.0030.08018.91
5.4.360.0100.07319.09
5.4.350.0030.06719.04
5.4.340.0130.07718.88
5.4.320.0170.07019.19
5.4.310.0030.06319.13
5.4.300.0170.07019.02
5.4.290.0030.07319.20
5.4.280.0070.05318.90
5.4.270.0070.05719.11
5.4.260.0170.05319.16
5.4.250.0070.04019.12
5.4.240.0070.04718.87
5.4.230.0070.07719.13
5.4.220.0170.07018.87
5.4.210.0130.03718.94
5.4.200.0000.04718.89
5.4.190.0100.07719.11
5.4.180.0070.03319.02
5.4.170.0130.03318.84
5.4.160.0100.03318.86
5.4.150.0030.07719.10
5.4.140.0200.06016.47
5.4.130.0070.08016.45
5.4.120.0070.07316.47
5.4.110.0030.05016.48
5.4.100.0030.07716.52
5.4.90.0030.05316.54
5.4.80.0130.06716.54
5.4.70.0100.06716.52
5.4.60.0030.06016.48
5.4.50.0030.07716.41
5.4.40.0130.07316.36
5.4.30.0000.06016.44
5.4.20.0130.06716.48
5.4.10.0030.08016.43
5.4.00.0030.04015.85
5.3.290.0070.06714.68
5.3.280.0130.03714.55
5.3.270.0100.06014.65
5.3.260.0000.08714.73
5.3.250.0100.05014.63
5.3.240.0170.06714.65
5.3.230.0100.07314.69
5.3.220.0100.05714.55
5.3.210.0100.07014.58
5.3.200.0070.07314.53
5.3.190.0130.04714.58
5.3.180.0100.06014.57
5.3.170.0000.05014.71
5.3.160.0030.04314.63
5.3.150.0070.04014.56
5.3.140.0030.07314.70
5.3.130.0130.07014.55
5.3.120.0030.04714.55
5.3.110.0070.04314.67
5.3.100.0070.07314.08
5.3.90.0100.03714.18
5.3.80.0030.08014.09
5.3.70.0030.07314.19
5.3.60.0000.04014.04
5.3.50.0000.04313.90
5.3.40.0070.05713.90
5.3.30.0070.03313.99
5.3.20.0100.03713.72
5.3.10.0000.04313.69
5.3.00.0000.06013.73
5.2.170.0070.04311.24
5.2.160.0030.05311.25
5.2.150.0070.04011.23
5.2.140.0000.03311.26
5.2.130.0030.05311.16
5.2.120.0000.03711.03
5.2.110.0000.04311.12
5.2.100.0000.05711.12
5.2.90.0070.03011.06
5.2.80.0070.04711.26
5.2.70.0030.03711.18
5.2.60.0030.03311.00
5.2.50.0000.03711.04
5.2.40.0030.06011.09
5.2.30.0100.05311.01
5.2.20.0000.06311.13
5.2.10.0070.04010.75
5.2.00.0000.05310.80
5.1.60.0030.02710.28
5.1.50.0000.02710.28
5.1.40.0100.02710.28
5.1.30.0030.02310.48
5.1.20.0000.05010.41
5.1.10.0170.01310.28
5.1.00.0000.03310.28
5.0.50.0000.02010.28
5.0.40.0000.02010.28
5.0.30.0000.05010.28
5.0.20.0000.01710.28
5.0.10.0000.03710.28
5.0.00.0030.05010.28
4.4.90.0030.01310.28
4.4.80.0000.01710.28
4.4.70.0030.01710.28
4.4.60.0030.03310.28
4.4.50.0100.02010.28
4.4.40.0030.02310.28
4.4.30.0030.03310.28
4.4.20.0030.02710.28
4.4.10.0030.01310.28
4.4.00.0000.02710.28
4.3.110.0030.02710.28
4.3.100.0070.03010.28
4.3.90.0030.01710.28
4.3.80.0000.02710.28
4.3.70.0000.03710.28
4.3.60.0000.02310.28
4.3.50.0070.03010.28
4.3.40.0000.02710.28
4.3.30.0000.02310.28
4.3.20.0000.03310.28
4.3.10.0000.02310.28
4.3.00.0070.01710.28

preferences:
76.95 ms | 401 KiB | 5 Q