3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php date_default_timezone_set('America/New_York'); $start = new DateTime('this year'); $end = new DateTime('+10 years'); $interval = new DateInterval('P1Y'); $adjust = 'fourth thursday of November'; $period = new DatePeriod($start, $interval, $end); foreach($period as $holiday) { $holiday->modify($adjust); echo "Thanksgiving in {$holiday->format('Y')} will be on {$holiday->format('l F jS')}\n"; }
Output for 5.3.6 - 5.4.32, 5.6.28, 7.0.14 - 7.1.0
Thanksgiving in 2014 will be on Thursday November 27th Thanksgiving in 2015 will be on Thursday November 26th Thanksgiving in 2016 will be on Thursday November 24th Thanksgiving in 2017 will be on Thursday November 23rd Thanksgiving in 2018 will be on Thursday November 22nd Thanksgiving in 2019 will be on Thursday November 28th Thanksgiving in 2020 will be on Thursday November 26th Thanksgiving in 2021 will be on Thursday November 25th Thanksgiving in 2022 will be on Thursday November 24th Thanksgiving in 2023 will be on Thursday November 23rd
Output for 5.5.24 - 5.6.21, 7.0.0 - 7.0.6
Thanksgiving in 2016 will be on Thursday November 24th Thanksgiving in 2017 will be on Thursday November 23rd Thanksgiving in 2018 will be on Thursday November 22nd Thanksgiving in 2019 will be on Thursday November 28th Thanksgiving in 2020 will be on Thursday November 26th Thanksgiving in 2021 will be on Thursday November 25th Thanksgiving in 2022 will be on Thursday November 24th Thanksgiving in 2023 will be on Thursday November 23rd Thanksgiving in 2024 will be on Thursday November 28th Thanksgiving in 2025 will be on Thursday November 27th
Output for 5.4.34 - 5.4.45
Thanksgiving in 2015 will be on Thursday November 26th Thanksgiving in 2016 will be on Thursday November 24th Thanksgiving in 2017 will be on Thursday November 23rd Thanksgiving in 2018 will be on Thursday November 22nd Thanksgiving in 2019 will be on Thursday November 28th Thanksgiving in 2020 will be on Thursday November 26th Thanksgiving in 2021 will be on Thursday November 25th Thanksgiving in 2022 will be on Thursday November 24th Thanksgiving in 2023 will be on Thursday November 23rd Thanksgiving in 2024 will be on Thursday November 28th
Output for 5.3.0 - 5.3.5
Thanksgiving in 2014 will be on Thursday April 24th Thanksgiving in 2015 will be on Thursday April 23rd Thanksgiving in 2016 will be on Thursday April 28th Thanksgiving in 2017 will be on Thursday April 27th Thanksgiving in 2018 will be on Thursday April 26th Thanksgiving in 2019 will be on Thursday April 25th Thanksgiving in 2020 will be on Thursday April 23rd Thanksgiving in 2021 will be on Thursday April 22nd Thanksgiving in 2022 will be on Thursday April 28th Thanksgiving in 2023 will be on Thursday April 27th
Output for 5.2.0 - 5.2.17
Fatal error: Class 'DateInterval' not found in /in/FV18R on line 5
Process exited with code 255.
Output for 5.1.0 - 5.1.6
Fatal error: Class 'DateTime' not found in /in/FV18R on line 3
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Fatal error: Call to undefined function date_default_timezone_set() in /in/FV18R on line 2
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected '(', expecting '}' in /in/FV18R on line 11
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected '(', expecting '}' in /in/FV18R on line 11
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `'}'' in /in/FV18R on line 11
Process exited with code 255.