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 + 21 sec"; $str2 = "2009-01-01 + 54061 sec"; $tempdate1 = $str1; $date1 = new DateTime($str1); $n = 0; $date2 = new DateTime($tempdate1); $interval = $date1->diff($date2); $string1 = "(" . $interval->days . ") difference " . $interval->y . " years, " . $interval->m . " months, " . $interval->d . " days"; $mydate = dateDiff(strtotime($str1), strtotime($tempdate1)); $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.70.0090.00916.50
8.3.60.0000.01518.45
8.3.50.0130.01017.42
8.3.40.0130.00318.95
8.3.30.0090.00618.82
8.3.20.0030.00519.02
8.3.10.0050.00318.88
8.3.00.0030.00619.38
8.2.180.0070.00716.88
8.2.170.0140.00722.96
8.2.160.0000.01518.91
8.2.150.0000.00924.18
8.2.140.0040.00424.66
8.2.130.0080.00026.16
8.2.120.0000.00820.75
8.2.110.0090.00920.99
8.2.100.0080.00318.16
8.2.90.0090.00617.99
8.2.80.0080.00017.97
8.2.70.0000.00817.88
8.2.60.0080.00018.04
8.2.50.0000.00818.07
8.2.40.0000.00819.49
8.2.30.0000.00817.88
8.2.20.0050.00517.76
8.2.10.0030.00618.05
8.2.00.0050.00318.25
8.1.280.0090.00625.92
8.1.270.0000.00823.99
8.1.260.0040.00426.35
8.1.250.0080.00028.09
8.1.240.0060.00322.51
8.1.230.0070.00421.00
8.1.220.0000.00817.91
8.1.210.0040.00418.97
8.1.200.0000.00917.50
8.1.190.0030.00617.61
8.1.180.0000.00818.10
8.1.170.0000.01118.94
8.1.160.0000.00718.98
8.1.150.0040.00418.86
8.1.140.0000.00817.72
8.1.130.0070.00019.41
8.1.120.0040.00417.73
8.1.110.0070.00017.53
8.1.100.0000.00717.64
8.1.90.0000.00717.63
8.1.80.0040.00417.73
8.1.70.0000.00717.55
8.1.60.0040.00417.77
8.1.50.0000.00817.73
8.1.40.0040.00417.73
8.1.30.0030.00617.71
8.1.20.0030.00917.79
8.1.10.0000.00717.67
8.1.00.0040.00417.61
8.0.300.0020.00520.11
8.0.290.0040.00417.00
8.0.280.0030.00318.58
8.0.270.0000.00717.27
8.0.260.0040.00417.11
8.0.250.0040.00417.14
8.0.240.0040.00417.21
8.0.230.0040.00417.25
8.0.220.0000.00717.05
8.0.210.0000.00717.11
8.0.200.0060.00017.21
8.0.190.0000.00717.19
8.0.180.0050.00217.18
8.0.170.0000.00817.12
8.0.160.0070.00017.20
8.0.150.0080.00016.99
8.0.140.0000.00717.04
8.0.130.0030.00313.61
8.0.120.0030.00717.03
8.0.110.0000.00717.15
8.0.100.0040.00417.00
8.0.90.0040.00417.09
8.0.80.0130.00617.12
8.0.70.0040.00417.24
8.0.60.0030.00616.96
8.0.50.0090.00017.05
8.0.30.0100.01017.26
8.0.20.0090.01117.38
8.0.10.0040.00417.29
8.0.00.0100.01116.85
7.4.330.0000.00513.12
7.4.320.0030.00316.66
7.4.300.0030.00316.66
7.4.290.0050.00516.75
7.4.280.0000.00716.55
7.4.270.0060.00316.63
7.4.260.0050.00013.37
7.4.250.0000.00816.78
7.4.240.0040.00416.75
7.4.230.0070.00016.58
7.4.220.0090.00916.69
7.4.210.0160.00016.71
7.4.200.0050.00216.63
7.4.190.0040.00416.90
7.4.160.0080.00816.49
7.4.150.0090.00916.81
7.4.140.0170.00317.86
7.4.130.0120.00616.72
7.4.120.0070.01116.73
7.4.110.0140.01116.59
7.4.100.0030.01316.66
7.4.90.0100.00716.43
7.4.80.0030.01319.39
7.4.70.0100.00716.65
7.4.60.0070.01416.76
7.4.50.0000.00416.59
7.4.40.0100.00716.54
7.4.30.0120.00516.71
7.4.00.0030.01315.26
7.3.330.0030.00313.50
7.3.320.0000.00613.49
7.3.310.0030.00316.63
7.3.300.0000.00716.51
7.3.290.0060.00916.66
7.3.280.0120.00916.57
7.3.270.0210.00316.57
7.3.260.0090.01516.71
7.3.240.0060.01116.79
7.3.230.0140.00416.79
7.3.210.0090.01316.83
7.3.200.0030.01416.83
7.3.190.0080.00816.68
7.3.180.0120.00916.61
7.3.170.0100.00716.58
7.3.160.0030.01316.59
7.3.120.0050.01015.15
7.3.110.0030.01215.01
7.3.100.0000.01615.18
7.3.90.0000.01214.75
7.3.80.0090.00314.91
7.3.70.0060.00915.06
7.3.60.0090.00614.98
7.3.50.0070.00314.94
7.3.40.0070.01015.03
7.3.30.0040.00415.01
7.3.20.0070.00716.75
7.3.10.0020.01316.79
7.3.00.0060.00716.63
7.2.330.0040.01416.59
7.2.320.0030.01716.70
7.2.310.0090.00916.97
7.2.300.0110.00716.77
7.2.290.0070.01016.95
7.2.250.0100.00715.32
7.2.240.0070.01315.05
7.2.230.0060.00914.82
7.2.220.0070.00715.43
7.2.210.0080.00415.37
7.2.200.0070.00715.04
7.2.190.0080.00415.36
7.2.180.0060.00915.14
7.2.170.0030.00715.05
7.2.130.0000.01417.14
7.2.120.0060.00917.11
7.2.110.0000.00917.15
7.2.100.0090.00617.22
7.2.90.0030.01017.19
7.2.80.0070.01116.88
7.2.70.0130.00017.24
7.2.60.0040.00717.12
7.2.50.0060.00917.15
7.2.40.0040.00417.01
7.2.30.0130.00317.01
7.2.20.0090.00917.31
7.2.10.0000.01117.25
7.2.00.0070.00718.47
7.1.330.0100.00716.09
7.1.320.0040.01215.58
7.1.310.0060.00315.95
7.1.300.0110.00416.16
7.1.290.0030.00915.63
7.1.280.0000.01416.02
7.1.270.0090.00315.92
7.1.260.0120.00016.00
7.1.250.0070.00415.80
7.1.100.0030.00618.23
7.1.70.0040.00417.57
7.1.60.0100.01319.25
7.1.50.0130.01016.98
7.1.00.0000.03722.54
7.0.200.0000.00916.59
7.0.140.0000.07322.05
7.0.120.0000.07722.02
7.0.100.0100.04321.69
7.0.90.0100.08321.80
7.0.80.0070.09020.17
7.0.70.0030.04721.61
7.0.60.0070.04321.69
7.0.50.0030.08022.14
7.0.40.0070.08020.02
7.0.30.0000.04320.11
7.0.20.0030.05020.19
7.0.10.0100.03720.09
7.0.00.0030.04320.10
5.6.250.0000.08020.77
5.6.240.0100.08320.64
5.6.230.0030.09020.55
5.6.220.0030.04020.51
5.6.210.0000.04320.61
5.6.200.0100.03720.96
5.6.190.0000.04721.05
5.6.180.0130.03321.13
5.6.170.0070.04020.98
5.6.160.0030.04321.13
5.6.150.0030.04021.19
5.6.140.0030.04721.00
5.6.130.0130.07721.06
5.6.120.0030.06721.06
5.6.110.0000.06021.05
5.6.100.0000.04321.01
5.6.90.0070.04021.18
5.6.80.0100.04320.44
5.6.70.0070.05020.33
5.6.60.0070.03720.38
5.6.50.0070.03720.44
5.6.40.0130.03320.41
5.6.30.0070.03020.41
5.6.20.0070.03720.38
5.6.10.0030.04020.53
5.6.00.0030.03320.44
5.5.380.0170.07020.57
5.5.370.0030.08320.36
5.5.360.0030.04320.54
5.5.350.0000.06320.47
5.5.340.0170.03020.95
5.5.330.0070.07720.92
5.5.320.0070.08020.93
5.5.310.0030.05020.90
5.5.300.0000.06320.93
5.5.290.0030.08720.79
5.5.280.0070.04020.92
5.5.270.0030.04720.82
5.5.260.0070.04320.79
5.5.250.0070.03720.70
5.5.240.0000.04020.20
5.5.230.0000.04320.30
5.5.220.0070.04020.18
5.5.210.0000.03320.18
5.5.200.0070.04020.26
5.5.190.0070.03720.25
5.5.180.0000.03720.23
5.5.160.0030.03020.29
5.5.150.0030.04020.14
5.5.140.0030.03020.00
5.5.130.0130.07020.27
5.5.120.0170.07020.09
5.5.110.0000.07720.17
5.5.100.0070.07720.18
5.5.90.0030.05020.03
5.5.80.0000.04720.17
5.5.70.0170.03320.07
5.5.60.0100.07719.98
5.5.50.0070.07020.17
5.5.40.0070.04720.16
5.5.30.0070.05020.10
5.5.20.0070.07720.05
5.5.10.0130.07020.12
5.5.00.0070.06720.14
5.4.450.0070.06719.21
5.4.440.0030.04019.46
5.4.430.0030.04019.55
5.4.420.0070.04319.53
5.4.410.0000.04019.07
5.4.400.0000.04318.90
5.4.390.0000.04319.13
5.4.380.0070.05018.90
5.4.370.0100.03019.23
5.4.360.0030.03719.21
5.4.350.0070.03318.88
5.4.340.0000.04319.21
5.4.320.0030.03319.04
5.4.310.0030.03719.23
5.4.300.0000.03719.12
5.4.290.0000.06319.18
5.4.280.0030.06019.16
5.4.270.0170.05319.03
5.4.260.0070.06719.12
5.4.250.0130.03719.20
5.4.240.0030.04319.21
5.4.230.0070.08718.91
5.4.220.0170.04018.87
5.4.210.0030.07719.03
5.4.200.0070.05319.12
5.4.190.0030.05019.15
5.4.180.0000.05019.17
5.4.170.0070.07718.95
5.4.160.0030.04319.03
5.4.150.0130.03719.16
5.4.140.0070.05716.41
5.4.130.0030.03716.45
5.4.120.0100.06316.43
5.4.110.0070.07716.52
5.4.100.0070.03716.56
5.4.90.0100.03316.45
5.4.80.0070.04016.41
5.4.70.0070.08016.42
5.4.60.0030.06316.37
5.4.50.0000.04316.47
5.4.40.0100.06016.35
5.4.30.0070.03716.31
5.4.20.0000.04716.45
5.4.10.0000.04016.27
5.4.00.0030.04315.81
5.3.290.0070.06014.70
5.3.280.0070.07714.74
5.3.270.0000.06314.64
5.3.260.0000.05014.56
5.3.250.0070.04314.59
5.3.240.0000.07014.66
5.3.230.0230.05714.68
5.3.220.0130.05714.52
5.3.210.0000.05014.74
5.3.200.0100.04314.52
5.3.190.0000.04014.66
5.3.180.0070.08014.66
5.3.170.0030.07314.66
5.3.160.0130.06714.72
5.3.150.0000.04014.62
5.3.140.0130.03714.57
5.3.130.0030.06314.53
5.3.120.0130.06714.66
5.3.110.0100.06014.60
5.3.100.0070.07314.18
5.3.90.0070.04314.15
5.3.80.0100.03014.06
5.3.70.0000.05314.05
5.3.60.0100.05014.02
5.3.50.0000.07714.08
5.3.40.0100.06314.00
5.3.30.0070.07013.98
5.3.20.0130.03313.70
5.3.10.0030.07313.69
5.3.00.0100.06713.80
5.2.170.0030.04011.55
5.2.160.0000.04711.55
5.2.150.0030.03711.55
5.2.140.0030.03711.55
5.2.130.0000.07011.55
5.2.120.0000.04011.55
5.2.110.0100.05311.55
5.2.100.0170.03311.55
5.2.90.0030.06011.55
5.2.80.0070.06011.55
5.2.70.0000.06711.55
5.2.60.0030.03311.55
5.2.50.0030.05711.55
5.2.40.0100.06011.55
5.2.30.0070.05711.55
5.2.20.0030.03711.55
5.2.10.0070.03011.55
5.2.00.0200.04311.55
5.1.60.0030.03711.55
5.1.50.0030.03711.55
5.1.40.0000.03011.55
5.1.30.0030.06011.55
5.1.20.0070.04311.55
5.1.10.0000.02711.55
5.1.00.0070.04711.55
5.0.50.0030.04711.55
5.0.40.0030.04011.55
5.0.30.0030.03011.55
5.0.20.0070.04011.55
5.0.10.0000.04711.55
5.0.00.0070.04011.55
4.4.90.0030.02311.55
4.4.80.0030.02711.55
4.4.70.0000.03711.55
4.4.60.0030.03011.55
4.4.50.0030.01711.55
4.4.40.0030.05311.55
4.4.30.0030.02311.55
4.4.20.0000.03011.55
4.4.10.0000.02011.55
4.4.00.0000.05011.55
4.3.110.0000.02711.55
4.3.100.0000.03011.55
4.3.90.0070.01311.55
4.3.80.0000.05711.55
4.3.70.0000.03311.55
4.3.60.0000.03711.55
4.3.50.0070.01311.55
4.3.40.0000.05011.55
4.3.30.0030.03311.55
4.3.20.0000.03311.55
4.3.10.0030.02011.55
4.3.00.0000.02011.55

preferences:
44.82 ms | 401 KiB | 5 Q