3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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'; foreach($period as $date){ echo $date->format($format) . ' => ' . getSameDayNextYear($date)->format($format) . "\n"; }
Output for 5.4.0 - 5.6.30, hhvm-3.10.1 - 3.17.3, 7.0.0 - 7.1.7
Wednesday 21-06-2017 => Wednesday 20-06-2018 Monday 26-06-2017 => Monday 25-06-2018 Saturday 01-07-2017 => Saturday 30-06-2018 Thursday 06-07-2017 => Thursday 05-07-2018 Tuesday 11-07-2017 => Tuesday 10-07-2018 Sunday 16-07-2017 => Sunday 15-07-2018 Friday 21-07-2017 => Friday 20-07-2018 Wednesday 26-07-2017 => Wednesday 25-07-2018 Monday 31-07-2017 => Monday 30-07-2018 Saturday 05-08-2017 => Saturday 04-08-2018 Thursday 10-08-2017 => Thursday 09-08-2018 Tuesday 15-08-2017 => Tuesday 14-08-2018 Sunday 20-08-2017 => Sunday 19-08-2018 Friday 25-08-2017 => Friday 24-08-2018 Wednesday 30-08-2017 => Wednesday 29-08-2018 Monday 04-09-2017 => Monday 03-09-2018 Saturday 09-09-2017 => Saturday 08-09-2018 Thursday 14-09-2017 => Thursday 13-09-2018 Tuesday 19-09-2017 => Tuesday 18-09-2018 Sunday 24-09-2017 => Sunday 23-09-2018 Friday 29-09-2017 => Friday 28-09-2018 Wednesday 04-10-2017 => Wednesday 03-10-2018 Monday 09-10-2017 => Monday 08-10-2018 Saturday 14-10-2017 => Saturday 13-10-2018 Thursday 19-10-2017 => Thursday 18-10-2018
Output for 5.3.0 - 5.3.29
Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /in/OtOYn on line 11
Process exited with code 255.
Output for 5.1.0 - 5.2.17
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/OtOYn on line 6 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/OtOYn on line 9 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/OtOYn on line 11 Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /in/OtOYn 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/OtOYn on line 6 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/OtOYn on line 9 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/OtOYn on line 11 Parse error: parse error, unexpected T_OBJECT_OPERATOR in /in/OtOYn 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/OtOYn on line 6 Parse error: syntax error, unexpected T_STRING, expecting ')' in /in/OtOYn on line 6
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/OtOYn on line 6 Parse error: parse error, unexpected T_STRING, expecting ')' in /in/OtOYn 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/OtOYn on line 6 Parse error: parse error, expecting `')'' in /in/OtOYn on line 6
Process exited with code 255.