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 = $inbetween / 60 / 60 / 24; return $dateObj; } $str1 = "1970-01-01"; $str2 = "2009-01-01"; $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"; 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.0090.00618.30
8.3.50.0150.00517.43
8.3.40.0080.00818.74
8.3.30.0090.00618.81
8.3.20.0080.00019.02
8.3.10.0000.00818.88
8.3.00.0080.00019.50
8.2.180.0040.01116.75
8.2.170.0090.00622.96
8.2.160.0150.00019.08
8.2.150.0040.00424.18
8.2.140.0030.00524.66
8.2.130.0050.00326.16
8.2.120.0080.00019.64
8.2.110.0030.00619.24
8.2.100.0080.00417.97
8.2.90.0060.00619.38
8.2.80.0000.00819.32
8.2.70.0030.00617.75
8.2.60.0030.00518.03
8.2.50.0050.00317.93
8.2.40.0000.00919.60
8.2.30.0040.00418.01
8.2.20.0000.01117.91
8.2.10.0030.00517.96
8.2.00.0000.00918.00
8.1.280.0070.00725.92
8.1.270.0040.00423.99
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0060.00322.76
8.1.230.0120.00017.76
8.1.220.0040.00417.74
8.1.210.0030.00618.77
8.1.200.0040.00417.60
8.1.190.0050.00317.47
8.1.180.0060.00318.10
8.1.170.0040.00417.62
8.1.160.0040.00419.05
8.1.150.0000.00918.75
8.1.140.0040.00417.52
8.1.130.0040.00417.68
8.1.120.0000.00817.68
8.1.110.0040.00417.57
8.1.100.0000.00817.51
8.1.90.0000.00717.65
8.1.80.0000.00817.59
8.1.70.0040.00417.59
8.1.60.0000.00917.70
8.1.50.0050.00317.48
8.1.40.0000.00917.66
8.1.30.0030.00617.71
8.1.20.0060.00317.82
8.1.10.0080.00017.57
8.1.00.0080.00017.45
8.0.300.0080.00318.77
8.0.290.0000.00916.73
8.0.280.0040.00418.52
8.0.270.0040.00417.29
8.0.260.0030.00318.39
8.0.250.0000.00917.21
8.0.240.0000.00717.24
8.0.230.0050.00317.16
8.0.220.0040.00417.14
8.0.210.0030.00617.11
8.0.200.0030.00617.22
8.0.190.0050.00317.20
8.0.180.0060.00617.16
8.0.170.0040.00417.11
8.0.160.0040.00417.18
8.0.150.0030.00617.06
8.0.140.0040.00417.06
8.0.130.0000.00613.46
8.0.120.0000.01017.13
8.0.110.0050.00217.09
8.0.100.0080.00017.09
8.0.90.0040.00417.11
8.0.80.0070.01017.13
8.0.70.0050.00316.92
8.0.60.0030.00617.06
8.0.50.0060.00316.98
8.0.30.0100.01317.25
8.0.20.0150.00417.38
8.0.10.0050.00317.19
8.0.00.0060.01516.79
7.4.330.0050.00013.08
7.4.320.0000.00716.67
7.4.300.0030.00316.69
7.4.290.0030.00716.74
7.4.280.0000.00816.70
7.4.270.0000.01016.65
7.4.260.0030.00313.30
7.4.250.0040.00416.55
7.4.240.0050.00316.67
7.4.230.0050.00216.75
7.4.220.0040.01616.75
7.4.210.0190.00316.69
7.4.200.0000.00816.79
7.4.190.0040.00416.59
7.4.160.0030.01316.69
7.4.150.0030.01516.50
7.4.140.0110.00817.86
7.4.130.0120.00716.74
7.4.120.0150.00316.69
7.4.110.0090.01516.82
7.4.100.0140.00616.53
7.4.90.0090.00916.61
7.4.80.0030.01919.39
7.4.70.0110.00716.77
7.4.60.0130.00316.56
7.4.50.0050.00016.80
7.4.40.0060.00616.63
7.4.30.0060.01916.53
7.4.00.0090.00615.04
7.3.330.0060.00013.53
7.3.320.0040.00413.46
7.3.310.0040.00416.54
7.3.300.0000.00716.57
7.3.290.0100.00716.56
7.3.280.0100.01016.57
7.3.270.0110.00616.75
7.3.260.0060.01316.43
7.3.240.0140.00716.71
7.3.230.0100.00716.50
7.3.210.0100.00716.42
7.3.200.0060.01116.67
7.3.190.0110.00516.50
7.3.180.0100.00716.66
7.3.170.0140.00916.57
7.3.160.0150.00016.52
7.3.120.0100.00715.09
7.2.330.0110.01416.81
7.2.320.0030.01516.88
7.2.310.0030.01617.01
7.2.300.0090.00916.77
7.2.290.0030.01816.84
7.2.00.0070.00719.40
7.1.70.0060.00317.31
7.1.60.0130.01319.25
7.1.50.0100.01316.89
7.1.00.0000.04722.32
7.0.200.0080.00016.94
7.0.140.0000.08022.09
7.0.120.0130.06721.96
7.0.80.0230.07020.04
7.0.70.0100.08719.92
7.0.60.0170.08019.92
7.0.50.0100.08720.29
7.0.40.0070.05720.18
7.0.30.0130.07720.17
7.0.20.0070.08020.11
7.0.10.0100.05320.14
7.0.00.0030.05019.94
5.6.280.0000.07721.09
5.6.230.0130.08020.73
5.6.220.0070.06320.62
5.6.210.0030.08320.64
5.6.200.0100.08720.96
5.6.190.0200.07321.03
5.6.180.0130.06321.04
5.6.170.0100.08321.08
5.6.160.0070.04020.98
5.6.150.0000.09021.16
5.6.140.0030.04321.12
5.6.130.0130.08320.95
5.6.120.0100.08720.97
5.6.110.0070.04321.07
5.6.100.0100.07021.14
5.6.90.0130.05321.11
5.6.80.0100.08720.48
5.6.70.0130.05320.48
5.6.60.0100.04720.36
5.6.50.0030.05320.50
5.6.40.0070.04020.33
5.6.30.0070.04020.52
5.6.20.0070.07320.39
5.6.10.0170.07320.39
5.6.00.0100.07320.49
5.5.370.0100.06320.38
5.5.360.0070.08020.46
5.5.350.0070.08320.39
5.5.340.0130.05720.91
5.5.330.0070.08020.76
5.5.320.0130.07320.82
5.5.310.0070.06020.89
5.5.300.0070.04020.78
5.5.290.0100.06720.93
5.5.280.0030.08720.88
5.5.270.0030.08720.87
5.5.260.0030.09020.74
5.5.250.0030.08320.73
5.5.240.0130.04020.18
5.5.230.0070.07020.24
5.5.220.0030.08320.19
5.5.210.0030.08020.18
5.5.200.0100.03320.15
5.5.190.0000.04719.97
5.5.180.0070.07020.27
5.5.160.0070.08720.19
5.5.150.0000.07020.19
5.5.140.0000.08720.19
5.5.130.0130.04720.01
5.5.120.0100.07320.21
5.5.110.0130.07320.12
5.5.100.0030.04320.11
5.5.90.0100.08320.08
5.5.80.0170.07720.12
5.5.70.0200.03720.12
5.5.60.0030.09720.17
5.5.50.0100.05020.08
5.5.40.0070.05320.16
5.5.30.0100.08720.08
5.5.20.0170.05020.10
5.5.10.0030.07320.02
5.5.00.0070.08020.14
5.4.450.0070.07719.47
5.4.440.0070.08019.53
5.4.430.0130.07719.46
5.4.420.0130.07319.46
5.4.410.0030.08019.23
5.4.400.0030.07719.20
5.4.390.0030.08719.03
5.4.380.0070.08019.10
5.4.370.0170.06719.13
5.4.360.0030.05019.04
5.4.350.0070.07318.88
5.4.340.0030.06019.18
5.4.320.0130.04318.87
5.4.310.0070.06318.85
5.4.300.0030.08319.13
5.4.290.0100.05719.23
5.4.280.0130.06019.12
5.4.270.0070.07719.21
5.4.260.0030.05318.94
5.4.250.0070.05319.20
5.4.240.0030.07719.12
5.4.230.0070.08019.04
5.4.220.0000.04318.90
5.4.210.0170.06019.13
5.4.200.0100.06719.20
5.4.190.0000.05319.20
5.4.180.0170.07019.04
5.4.170.0070.08319.11
5.4.160.0000.08018.86
5.4.150.0000.08018.89
5.4.140.0070.07716.46
5.4.130.0070.04716.50
5.4.120.0070.07016.49
5.4.110.0070.07716.54
5.4.100.0100.07016.41
5.4.90.0030.04316.45
5.4.80.0100.04016.52
5.4.70.0030.07316.42
5.4.60.0030.06016.42
5.4.50.0070.06316.30
5.4.40.0030.04716.57
5.4.30.0000.07716.47
5.4.20.0070.07316.41
5.4.10.0000.06016.46
5.4.00.0070.07315.86
5.3.290.0070.08014.83
5.3.280.0100.04014.68
5.3.270.0070.09014.70
5.3.260.0070.06014.76
5.3.250.0000.06014.66
5.3.240.0230.05314.75
5.3.230.0070.04714.59
5.3.220.0100.07014.72
5.3.210.0000.05714.73
5.3.200.0070.07714.62
5.3.190.0130.09014.52
5.3.180.0030.09314.61
5.3.170.0070.07314.61
5.3.160.0170.07714.57
5.3.150.0030.08014.65
5.3.140.0170.06714.73
5.3.130.0070.04014.51
5.3.120.0170.08714.59
5.3.110.0070.08014.60
5.3.100.0130.07014.03
5.3.90.0030.05714.03
5.3.80.0100.07313.93
5.3.70.0070.06714.18
5.3.60.0100.07313.95
5.3.50.0000.08714.07
5.3.40.0130.07313.90
5.3.30.0070.07314.00
5.3.20.0030.07013.84
5.3.10.0070.07013.66
5.3.00.0100.07713.78

preferences:
39.44 ms | 401 KiB | 5 Q