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('-6 months'); $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"; }
based on avt7Y
Output for 5.6.0 - 5.6.30, hhvm-3.15.4, 7.0.0 - 7.3.0rc3
Wednesday 21-12-2016 => Wednesday 16-12-2015 Monday 26-12-2016 => Monday 21-12-2015 Saturday 31-12-2016 => Saturday 26-12-2015 Thursday 05-01-2017 => Thursday 07-01-2016 Tuesday 10-01-2017 => Tuesday 12-01-2016 Sunday 15-01-2017 => Sunday 17-01-2016 Friday 20-01-2017 => Friday 22-01-2016 Wednesday 25-01-2017 => Wednesday 27-01-2016 Monday 30-01-2017 => Monday 01-02-2016 Saturday 04-02-2017 => Saturday 06-02-2016 Thursday 09-02-2017 => Thursday 11-02-2016 Tuesday 14-02-2017 => Tuesday 16-02-2016 Sunday 19-02-2017 => Sunday 21-02-2016 Friday 24-02-2017 => Friday 26-02-2016 Wednesday 01-03-2017 => Wednesday 02-03-2016 Monday 06-03-2017 => Monday 07-03-2016 Saturday 11-03-2017 => Saturday 12-03-2016 Thursday 16-03-2017 => Thursday 17-03-2016 Tuesday 21-03-2017 => Tuesday 22-03-2016 Sunday 26-03-2017 => Sunday 27-03-2016 Friday 31-03-2017 => Friday 01-04-2016 Wednesday 05-04-2017 => Wednesday 06-04-2016 Monday 10-04-2017 => Monday 11-04-2016 Saturday 15-04-2017 => Saturday 16-04-2016 Thursday 20-04-2017 => Thursday 21-04-2016 Tuesday 25-04-2017 => Tuesday 26-04-2016 Sunday 30-04-2017 => Sunday 01-05-2016 Friday 05-05-2017 => Friday 06-05-2016 Wednesday 10-05-2017 => Wednesday 11-05-2016 Monday 15-05-2017 => Monday 16-05-2016 Saturday 20-05-2017 => Saturday 21-05-2016 Thursday 25-05-2017 => Thursday 26-05-2016 Tuesday 30-05-2017 => Tuesday 31-05-2016 Sunday 04-06-2017 => Sunday 05-06-2016 Friday 09-06-2017 => Friday 10-06-2016 Wednesday 14-06-2017 => Wednesday 15-06-2016 Monday 19-06-2017 => Monday 20-06-2016 Saturday 24-06-2017 => Saturday 25-06-2016 Thursday 29-06-2017 => Thursday 30-06-2016 Tuesday 04-07-2017 => Tuesday 05-07-2016 Sunday 09-07-2017 => Sunday 10-07-2016 Friday 14-07-2017 => Friday 15-07-2016 Wednesday 19-07-2017 => Wednesday 20-07-2016 Monday 24-07-2017 => Monday 25-07-2016 Saturday 29-07-2017 => Saturday 30-07-2016 Thursday 03-08-2017 => Thursday 04-08-2016 Tuesday 08-08-2017 => Tuesday 09-08-2016 Sunday 13-08-2017 => Sunday 14-08-2016 Friday 18-08-2017 => Friday 19-08-2016 Wednesday 23-08-2017 => Wednesday 24-08-2016 Monday 28-08-2017 => Monday 29-08-2016 Saturday 02-09-2017 => Saturday 03-09-2016 Thursday 07-09-2017 => Thursday 08-09-2016 Tuesday 12-09-2017 => Tuesday 13-09-2016 Sunday 17-09-2017 => Sunday 18-09-2016 Friday 22-09-2017 => Friday 23-09-2016 Wednesday 27-09-2017 => Wednesday 28-09-2016 Monday 02-10-2017 => Monday 03-10-2016 Saturday 07-10-2017 => Saturday 08-10-2016 Thursday 12-10-2017 => Thursday 13-10-2016 Tuesday 17-10-2017 => Tuesday 18-10-2016