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'; foreach($period as $date){ echo $date->format($format) . ' => ' . getSameDayNextYear($date)->format($format) . "\n"; }
Output for 8.4.1 - 8.4.2
Deprecated: getSameDayNextYear(): Implicitly marking parameter $date as nullable is deprecated, the explicit nullable type must be used instead in /in/OtOYn on line 6 Thursday 03-11-2022 => Thursday 02-11-2023 Tuesday 08-11-2022 => Tuesday 07-11-2023 Sunday 13-11-2022 => Sunday 12-11-2023 Friday 18-11-2022 => Friday 17-11-2023 Wednesday 23-11-2022 => Wednesday 22-11-2023 Monday 28-11-2022 => Monday 27-11-2023 Saturday 03-12-2022 => Saturday 02-12-2023 Thursday 08-12-2022 => Thursday 07-12-2023 Tuesday 13-12-2022 => Tuesday 12-12-2023 Sunday 18-12-2022 => Sunday 17-12-2023 Friday 23-12-2022 => Friday 22-12-2023 Wednesday 28-12-2022 => Wednesday 27-12-2023 Monday 02-01-2023 => Monday 01-01-2024 Saturday 07-01-2023 => Saturday 06-01-2024 Thursday 12-01-2023 => Thursday 11-01-2024 Tuesday 17-01-2023 => Tuesday 16-01-2024 Sunday 22-01-2023 => Sunday 21-01-2024 Friday 27-01-2023 => Friday 26-01-2024 Wednesday 01-02-2023 => Wednesday 31-01-2024 Monday 06-02-2023 => Monday 05-02-2024 Saturday 11-02-2023 => Saturday 10-02-2024 Thursday 16-02-2023 => Thursday 15-02-2024 Tuesday 21-02-2023 => Tuesday 20-02-2024 Sunday 26-02-2023 => Sunday 25-02-2024 Friday 03-03-2023 => Friday 01-03-2024
Output for 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.34, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.31, 8.2.0 - 8.2.26, 8.3.0 - 8.3.14
Thursday 03-11-2022 => Thursday 02-11-2023 Tuesday 08-11-2022 => Tuesday 07-11-2023 Sunday 13-11-2022 => Sunday 12-11-2023 Friday 18-11-2022 => Friday 17-11-2023 Wednesday 23-11-2022 => Wednesday 22-11-2023 Monday 28-11-2022 => Monday 27-11-2023 Saturday 03-12-2022 => Saturday 02-12-2023 Thursday 08-12-2022 => Thursday 07-12-2023 Tuesday 13-12-2022 => Tuesday 12-12-2023 Sunday 18-12-2022 => Sunday 17-12-2023 Friday 23-12-2022 => Friday 22-12-2023 Wednesday 28-12-2022 => Wednesday 27-12-2023 Monday 02-01-2023 => Monday 01-01-2024 Saturday 07-01-2023 => Saturday 06-01-2024 Thursday 12-01-2023 => Thursday 11-01-2024 Tuesday 17-01-2023 => Tuesday 16-01-2024 Sunday 22-01-2023 => Sunday 21-01-2024 Friday 27-01-2023 => Friday 26-01-2024 Wednesday 01-02-2023 => Wednesday 31-01-2024 Monday 06-02-2023 => Monday 05-02-2024 Saturday 11-02-2023 => Saturday 10-02-2024 Thursday 16-02-2023 => Thursday 15-02-2024 Tuesday 21-02-2023 => Tuesday 20-02-2024 Sunday 26-02-2023 => Sunday 25-02-2024
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.

preferences:
102.03 ms | 414 KiB | 6 Q