3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $today = new DateTime(); $rangeStart = new DateTime(((int) $today->format('Y') - 3) . '-01-01 00:00:00'); $rangeEnd = new DateTime(((int) $today->format('Y') + 10) . '-12-31 23:59:59'); $datePeriod = new DatePeriod($rangeStart, new DateInterval('P6M'), $rangeEnd); print_r($datePeriod);
Output for 7.1.0 - 7.2.0
DatePeriod Object ( [start] => DateTime Object ( [date] => 2013-01-01 00:00:00.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) [current] => [end] => DateTime Object ( [date] => 2026-12-31 23:59:59.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) [interval] => DateInterval Object ( [y] => 0 [m] => 6 [d] => 0 [h] => 0 [i] => 0 [s] => 0 [f] => 0 [weekday] => 0 [weekday_behavior] => 0 [first_last_day_of] => 0 [invert] => 0 [days] => [special_type] => 0 [special_amount] => 0 [have_weekday_relative] => 0 [have_special_relative] => 0 ) [recurrences] => 1 [include_start_date] => 1 )
Output for 5.4.30 - 7.0.20
DatePeriod Object ( [start] => DateTime Object ( [date] => 2013-01-01 00:00:00.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) [current] => [end] => DateTime Object ( [date] => 2026-12-31 23:59:59.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) [interval] => DateInterval Object ( [y] => 0 [m] => 6 [d] => 0 [h] => 0 [i] => 0 [s] => 0 [weekday] => 0 [weekday_behavior] => 0 [first_last_day_of] => 0 [invert] => 0 [days] => [special_type] => 0 [special_amount] => 0 [have_weekday_relative] => 0 [have_special_relative] => 0 ) [recurrences] => 1 [include_start_date] => 1 )
Output for 5.3.27 - 5.3.29, 5.4.17 - 5.4.29
DatePeriod Object ( [start] => DateTime Object ( [date] => 2013-01-01 00:00:00 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) [current] => [end] => DateTime Object ( [date] => 2026-12-31 23:59:59 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) [interval] => DateInterval Object ( [y] => 0 [m] => 6 [d] => 0 [h] => 0 [i] => 0 [s] => 0 [weekday] => 0 [weekday_behavior] => 0 [first_last_day_of] => 0 [invert] => 0 [days] => [special_type] => 0 [special_amount] => 0 [have_weekday_relative] => 0 [have_special_relative] => 0 ) [recurrences] => 1 [include_start_date] => 1 )
Output for 5.3.21 - 5.3.26, 5.4.11 - 5.4.16
DatePeriod Object ( )