3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * @param \DateTime $date Date of the original meeting * @return \DateTime Date of the next meeting */ function getSameDayNextYear(\DateTime $date = null) { if(!$date){ $date = new \DateTime(); } return (new \DateTime())->setISODate((int)$date->format('o') + 1, (int)$date->format('W'), (int)$date->format('N')); } $start = new \DateTime(); $end = new \DateTime('+ 4 months'); $interval = new \DateInterval('P5D'); $period = new \DatePeriod($start, $interval, $end); $format = 'l d-m-Y'; $date = new \DateTime('2014-05-23'); for($i = 0; $i < 100; $i++){ echo $date->format($format) . "<br/>\n"; $date = getSameDayNextYear($date); }
Output for 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.12 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Friday 23-05-2014<br/> Friday 22-05-2015<br/> Friday 27-05-2016<br/> Friday 26-05-2017<br/> Friday 25-05-2018<br/> Friday 24-05-2019<br/> Friday 22-05-2020<br/> Friday 28-05-2021<br/> Friday 27-05-2022<br/> Friday 26-05-2023<br/> Friday 24-05-2024<br/> Friday 23-05-2025<br/> Friday 22-05-2026<br/> Friday 28-05-2027<br/> Friday 26-05-2028<br/> Friday 25-05-2029<br/> Friday 24-05-2030<br/> Friday 23-05-2031<br/> Friday 21-05-2032<br/> Friday 27-05-2033<br/> Friday 26-05-2034<br/> Friday 25-05-2035<br/> Friday 23-05-2036<br/> Friday 22-05-2037<br/> Friday 28-05-2038<br/> Friday 27-05-2039<br/> Friday 25-05-2040<br/> Friday 24-05-2041<br/> Friday 23-05-2042<br/> Friday 22-05-2043<br/> Friday 27-05-2044<br/> Friday 26-05-2045<br/> Friday 25-05-2046<br/> Friday 24-05-2047<br/> Friday 22-05-2048<br/> Friday 28-05-2049<br/> Friday 27-05-2050<br/> Friday 26-05-2051<br/> Friday 24-05-2052<br/> Friday 23-05-2053<br/> Friday 22-05-2054<br/> Friday 28-05-2055<br/> Friday 26-05-2056<br/> Friday 25-05-2057<br/> Friday 24-05-2058<br/> Friday 23-05-2059<br/> Friday 21-05-2060<br/> Friday 27-05-2061<br/> Friday 26-05-2062<br/> Friday 25-05-2063<br/> Friday 23-05-2064<br/> Friday 22-05-2065<br/> Friday 28-05-2066<br/> Friday 27-05-2067<br/> Friday 25-05-2068<br/> Friday 24-05-2069<br/> Friday 23-05-2070<br/> Friday 22-05-2071<br/> Friday 27-05-2072<br/> Friday 26-05-2073<br/> Friday 25-05-2074<br/> Friday 24-05-2075<br/> Friday 22-05-2076<br/> Friday 28-05-2077<br/> Friday 27-05-2078<br/> Friday 26-05-2079<br/> Friday 24-05-2080<br/> Friday 23-05-2081<br/> Friday 22-05-2082<br/> Friday 28-05-2083<br/> Friday 26-05-2084<br/> Friday 25-05-2085<br/> Friday 24-05-2086<br/> Friday 23-05-2087<br/> Friday 21-05-2088<br/> Friday 27-05-2089<br/> Friday 26-05-2090<br/> Friday 25-05-2091<br/> Friday 23-05-2092<br/> Friday 22-05-2093<br/> Friday 28-05-2094<br/> Friday 27-05-2095<br/> Friday 25-05-2096<br/> Friday 24-05-2097<br/> Friday 23-05-2098<br/> Friday 22-05-2099<br/> Friday 28-05-2100<br/> Friday 27-05-2101<br/> Friday 26-05-2102<br/> Friday 25-05-2103<br/> Friday 23-05-2104<br/> Friday 22-05-2105<br/> Friday 28-05-2106<br/> Friday 27-05-2107<br/> Friday 25-05-2108<br/> Friday 24-05-2109<br/> Friday 23-05-2110<br/> Friday 22-05-2111<br/> Friday 27-05-2112<br/> Friday 26-05-2113<br/>
Output for 5.3.0 - 5.3.29
Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /in/IIShI on line 11
Process exited with code 255.
Output for 5.1.0 - 5.1.6, 5.2.0 - 5.2.17
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/IIShI on line 6 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/IIShI on line 9 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/IIShI on line 11 Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /in/IIShI on line 11
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/IIShI on line 6 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/IIShI on line 9 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/IIShI on line 11 Parse error: parse error, unexpected T_OBJECT_OPERATOR in /in/IIShI on line 11
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/IIShI on line 6 Parse error: syntax error, unexpected T_STRING, expecting ')' in /in/IIShI on line 6
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/IIShI on line 6 Parse error: parse error, unexpected T_STRING, expecting ')' in /in/IIShI on line 6
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/IIShI on line 6 Parse error: parse error, expecting `')'' in /in/IIShI on line 6
Process exited with code 255.

preferences:
262.18 ms | 401 KiB | 358 Q