3v4l.org

run code in 300+ PHP versions simultaneously
<?php $base = new DateTime("2000-03-04 00:00:00 Europe/Berlin"); $date = new DateTime("2016-09-04 00:00:00 Europe/Berlin"); $interval = new DateInterval('P5Y6M1D'); $ret = $date; $diff = $base->diff($date); // var_dump($diff); $iterations = 0; if ($interval->y || $interval->m || $interval->d) { $y = $base->format('Y'); $m = $base->format('m'); $d = $base->format('d'); if ($interval->y || $interval->m) { $monthDiff = $diff->y * 12 + $diff->m; $monthInterval = $interval->y * 12 + $interval->m; $iterations = ceil($monthDiff / $monthInterval); $y = $base->format('Y') + ($interval->y * $iterations); $m = $base->format('m') + ($interval->m * $iterations); echo "set y:{$y}, m:{$m}, iterations:{$iterations}\n"; } if ($interval->d) { var_dump($diff->d, ($interval->d * $iterations)); $modify = $diff->d - ($interval->d * $iterations); if ($modify > 0) { $d += $modify; $y += $interval->y; $m += $interval->m; $iterations++; } else { $d -= $modify; } echo "set y:{$y}, m:{$m}, d:{$d}, iterations:{$iterations}\n"; } $ret->setDate($y, $m, $d); } echo $ret->format("Y-m-d H:i:s") . "\n"; exit; if ($interval->y) { $y = $diff->y / $interval->y; if ($y) { $intervals = $y / $interval->y; $m = $interval->m * $intervals; $y -= floor($m / 12); $m -= floor($m / 12) * 12; $ret->setDate( $base->format('Y') + $y, $base->format('m') + $m, $base->format('d') ); /* $ret->setTime( $base->format('G') + ($interval->h * $intervals), $base->format('i') + ($interval->i * $intervals), $base->format('s') + ($interval->s * $intervals) ); */ } } var_dump($ret); exit; $intervalMonths = $interval->m ?: 12; $m = ceil($diff->m / $intervalMonths) * $intervalMonths; if ($interval->d) { $d = ceil($diff->d / $interval->d) * $interval->d; } else { $d = 0; } $intervalHours = $interval->h ?: 24; $intervalMinutes = $interval->i ?: 60; $intervalSeconds = $interval->s ?: 60; $h = ceil($diff->h / $intervalHours) * $intervalHours; $i = ($h) ? $interval->i : ceil($diff->i / $intervalMinutes) * $intervalMinutes; $s = ($h || $i) ? $interval->s : ceil($diff->s / $intervalSeconds) * $intervalSeconds; if ($interval->d) { $d = ceil($diff->d / $interval->d) * $interval->d; } if ($interval->m) { $m = ceil($diff->m / $interval->m) * $interval->m; } if ($interval->y) { $y = ceil($diff->y / $interval->y) * $interval->y; } $s += $base->format('s'); $i += $base->format('i'); $h += $base->format('G'); $d += $base->format('d'); $m += $base->format('m'); $y += $base->format('Y'); $ret->setTime($h, $i, $s); //$ret->setDate($y, $m, $d); return $ret;

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.00918.55
8.3.50.0160.00622.05
8.3.40.0100.00619.22
8.3.30.0100.00319.17
8.3.20.0040.00420.16
8.3.10.0040.00421.90
8.3.00.0080.00019.20
8.2.180.0130.01018.66
8.2.170.0100.00722.96
8.2.160.0030.01322.13
8.2.150.0040.00424.18
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0040.00420.91
8.2.110.0030.00622.30
8.2.100.0090.00318.28
8.2.90.0000.00819.51
8.2.80.0050.00318.00
8.2.70.0000.01218.13
8.2.60.0030.00518.18
8.2.50.0040.00418.07
8.2.40.0000.00919.95
8.2.30.0050.00320.01
8.2.20.0000.00818.16
8.2.10.0030.00618.31
8.2.00.0050.00318.02
8.1.280.0150.00325.92
8.1.270.0040.00419.08
8.1.260.0040.00426.35
8.1.250.0000.00728.09
8.1.240.0090.00023.86
8.1.230.0090.00319.14
8.1.220.0040.00417.90
8.1.210.0000.00818.77
8.1.200.0000.00917.60
8.1.190.0080.00017.38
8.1.180.0050.00318.10
8.1.170.0030.00518.95
8.1.160.0090.00022.09
8.1.150.0060.00318.97
8.1.140.0040.00417.67
8.1.130.0000.00717.90
8.1.120.0080.00017.73
8.1.110.0080.00017.77
8.1.100.0000.00817.74
8.1.90.0040.00417.76
8.1.80.0030.00517.73
8.1.70.0000.00717.72
8.1.60.0030.00617.82
8.1.50.0120.00017.65
8.1.40.0030.00617.72
8.1.30.0050.00317.80
8.1.20.0000.00817.88
8.1.10.0040.00417.75
8.1.00.0040.00417.62
8.0.300.0030.00618.77
8.0.290.0000.00717.13
8.0.280.0070.00018.52
8.0.270.0070.00017.47
8.0.260.0030.00317.46
8.0.250.0000.00717.28
8.0.240.0050.00317.37
8.0.230.0000.00717.21
8.0.220.0070.00017.25
8.0.210.0050.00217.21
8.0.200.0040.00417.21
8.0.190.0000.01117.29
8.0.180.0070.00017.16
8.0.170.0050.00317.21
8.0.160.0000.00817.22
8.0.150.0030.00517.09
8.0.140.0050.00317.08
8.0.130.0000.00613.63
8.0.120.0000.00917.10
8.0.110.0040.00417.12
8.0.100.0000.00717.21
8.0.90.0000.00717.29
8.0.80.0120.00617.19
8.0.70.0040.00417.27
8.0.60.0040.00417.23
8.0.50.0040.00417.20
8.0.30.0080.01417.39
8.0.20.0110.00817.46
8.0.10.0050.00217.43
8.0.00.0140.00317.18
7.4.330.0000.00515.14
7.4.320.0000.00616.78
7.4.300.0060.00016.81
7.4.290.0030.00316.68
7.4.280.0040.00416.70
7.4.270.0030.00316.73
7.4.260.0050.00316.61
7.4.250.0000.00816.69
7.4.240.0050.00216.79
7.4.230.0030.00316.64
7.4.220.0120.00916.92
7.4.210.0040.01416.86
7.4.200.0040.00416.93
7.4.160.0070.01016.64
7.4.150.0060.01817.40
7.4.140.0160.00517.86
7.4.130.0120.00516.74
7.4.120.0080.01116.73
7.4.110.0090.01116.72
7.4.100.0050.01616.45
7.4.90.0140.00316.64
7.4.80.0090.00919.39
7.4.70.0080.00816.66
7.4.60.0090.00616.67
7.4.50.0000.00916.86
7.4.40.0070.01016.74
7.4.30.0110.01116.75
7.4.00.0070.00715.36
7.3.330.0060.00013.50
7.3.320.0030.00313.60
7.3.310.0070.00016.64
7.3.300.0060.00016.52
7.3.290.0100.00716.60
7.3.280.0130.00316.59
7.3.270.0100.00717.40
7.3.260.0000.01716.71
7.3.250.0140.00316.71
7.3.240.0000.01716.72
7.3.230.0080.00816.77
7.3.210.0100.01316.85
7.3.200.0100.00719.39
7.3.190.0170.00616.92
7.3.180.0070.01016.77
7.3.170.0150.00816.77
7.3.160.0140.00316.76
7.2.330.0120.00617.08
7.2.320.0060.01716.86
7.2.310.0140.00316.82
7.2.300.0090.00916.98
7.2.290.0070.01316.74
7.2.00.0090.00319.81
7.1.100.0070.00718.28
7.1.70.0050.00317.56
7.1.60.0090.00919.46
7.1.50.0000.01117.05
7.1.00.0070.07322.45
7.0.200.0000.00817.12
7.0.140.0100.02721.98
7.0.60.0030.08720.14
7.0.50.0030.07017.89
7.0.40.0170.08020.06
7.0.30.0230.05320.33
7.0.20.0200.04720.01
7.0.10.0130.08020.30
7.0.00.0070.05320.16
5.6.280.0070.07020.94
5.6.210.0130.07720.59
5.6.200.0170.07318.18
5.6.190.0100.04720.47
5.6.180.0230.04020.43
5.6.170.0170.04020.37
5.6.160.0030.05020.38
5.6.150.0070.07718.07
5.6.140.0030.04318.11
5.6.130.0030.08718.12
5.6.120.0100.07321.18
5.6.110.0100.08020.90
5.6.100.0130.07321.02
5.6.90.0070.08320.91
5.6.80.0070.08720.54
5.5.350.0030.08720.43
5.5.340.0070.05718.02
5.5.330.0100.06320.48
5.5.320.0170.05320.41
5.5.310.0230.07020.27
5.5.300.0130.07318.00
5.5.290.0000.04717.96
5.5.280.0030.06021.02
5.5.270.0070.08021.02
5.5.260.0170.07720.80
5.5.250.0000.06020.51
5.5.240.3730.03720.23
5.4.450.0430.06019.21
5.4.440.0430.06019.59
5.4.430.0000.06319.25
5.4.420.0130.05319.14
5.4.410.0130.05719.05
5.4.400.0170.05019.18
5.4.390.0000.06018.68
5.4.380.0130.05718.68
5.4.370.0870.06018.52
5.4.360.0830.06018.68
5.4.350.0800.05718.69
5.4.340.1000.05318.50
5.4.320.1000.04718.77
5.4.310.0930.05718.53
5.4.300.1000.08018.46
5.4.290.1000.04718.80
5.4.280.1030.07018.65
5.4.270.1100.06018.74
5.4.260.0930.05018.71
5.4.250.1030.05318.72
5.4.240.1000.05718.50
5.4.230.0970.04718.71
5.4.220.0930.05718.49
5.4.210.0900.05318.57
5.4.200.0900.05316.41
5.4.190.0870.05318.67
5.4.180.0900.05318.65
5.4.170.1030.04018.65
5.4.160.0870.05018.75
5.4.150.0870.05318.47
5.4.140.0870.05316.25
5.4.130.0930.04716.40
5.4.120.0930.05316.15
5.4.110.0870.05016.16
5.4.100.0900.05016.29
5.4.90.0970.04316.10
5.4.80.0830.05316.13
5.4.70.0830.06016.25
5.4.60.0930.05016.32
5.4.50.0830.05316.21
5.4.40.0870.05716.09
5.4.30.0900.05016.05
5.4.20.0870.06016.18
5.4.10.0930.04716.26
5.4.00.0930.05015.64
5.3.290.0930.05014.71
5.3.280.0830.05714.71
5.3.270.1030.05314.54
5.3.260.0970.06014.54
5.3.250.1070.04714.62
5.3.240.1130.04314.63
5.3.230.0970.05014.55
5.3.220.0870.06014.52
5.3.210.1070.05714.54
5.3.200.1170.05314.59
5.3.190.0900.05714.52
5.3.180.0830.05014.58
5.3.170.0970.05714.69
5.3.160.0930.06714.56
5.3.150.1100.06714.53
5.3.140.1170.06314.55
5.3.130.1070.06314.68
5.3.120.1030.05714.53
5.3.110.1130.05314.49
5.3.100.0900.07013.99
5.3.90.0930.06314.05
5.3.80.1070.05314.00
5.3.70.0930.05713.99
5.3.60.1070.06314.14
5.3.50.0970.06014.02
5.3.40.0970.05013.97
5.3.30.0970.06014.02
5.3.20.1030.04713.64
5.3.10.0870.05713.65
5.3.00.0900.05313.63
5.2.170.0870.03711.14
5.2.160.0830.04311.13
5.2.150.0800.05011.14
5.2.140.0800.04311.15
5.2.130.0830.04311.07
5.2.120.0770.04011.05
5.2.110.0900.04011.08
5.2.100.0830.04711.13
5.2.90.0930.02711.17
5.2.80.0800.04311.27
5.2.70.0830.05011.09
5.2.60.0930.03711.22
5.2.50.0800.04011.20
5.2.40.0530.04710.98
5.2.30.0600.04310.94
5.2.20.0670.03011.10
5.2.10.0670.03710.99
5.2.00.0700.03710.74
5.1.60.0730.04310.10
5.1.50.0670.03710.02
5.1.40.0870.03010.03
5.1.30.0630.03310.53
5.1.20.0670.04010.48
5.1.10.0830.03710.21
5.1.00.0570.04310.23
5.0.50.0470.0208.63
5.0.40.0400.0278.55
5.0.30.0430.0408.25
5.0.20.0130.0408.41
5.0.10.0370.0378.30
5.0.00.0370.0538.22
4.4.90.0300.0337.38
4.4.80.0270.0277.38
4.4.70.0330.0237.38
4.4.60.0200.0277.38
4.4.50.0400.0237.38
4.4.40.0370.0307.38
4.4.30.0400.0277.38
4.4.20.0330.0177.38
4.4.10.0270.0237.38
4.4.00.0130.0337.38
4.3.110.0030.0237.38
4.3.100.0170.0177.38
4.3.90.0170.0207.38
4.3.80.0470.0377.38
4.3.70.0100.0237.38
4.3.60.0330.0207.38
4.3.50.0430.0137.38
4.3.40.0130.0437.38
4.3.30.0030.0307.38
4.3.20.0170.0337.38
4.3.10.0230.0277.38
4.3.00.0100.0238.79

preferences:
43.27 ms | 401 KiB | 5 Q