3v4l.org

run code in 300+ PHP versions simultaneously
<?php $start = new DateTime('2012-07-01'); $interval = new DateInterval('P7D'); $end = new DateTime('2012-07-31'); $period = new DatePeriod($start, $interval, $end,DatePeriod::EXCLUDE_START_DATE); var_dump($period); foreach($period as $date) { var_dump($date); }
Output for 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
object(DatePeriod)#4 (7) { ["start"]=> object(DateTime)#5 (3) { ["date"]=> string(26) "2012-07-01 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } ["current"]=> NULL ["end"]=> object(DateTime)#6 (3) { ["date"]=> string(26) "2012-07-31 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } ["interval"]=> object(DateInterval)#7 (10) { ["y"]=> int(0) ["m"]=> int(0) ["d"]=> int(7) ["h"]=> int(0) ["i"]=> int(0) ["s"]=> int(0) ["f"]=> float(0) ["invert"]=> int(0) ["days"]=> bool(false) ["from_string"]=> bool(false) } ["recurrences"]=> int(0) ["include_start_date"]=> bool(false) ["include_end_date"]=> bool(false) } object(DateTime)#9 (3) { ["date"]=> string(26) "2012-07-08 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#11 (3) { ["date"]=> string(26) "2012-07-15 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#10 (3) { ["date"]=> string(26) "2012-07-22 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#9 (3) { ["date"]=> string(26) "2012-07-29 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.31, 7.4.0 - 7.4.33, 8.0.0 - 8.0.12, 8.0.14 - 8.0.30, 8.1.0 - 8.1.28
object(DatePeriod)#4 (6) { ["start"]=> object(DateTime)#5 (3) { ["date"]=> string(26) "2012-07-01 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } ["current"]=> NULL ["end"]=> object(DateTime)#6 (3) { ["date"]=> string(26) "2012-07-31 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } ["interval"]=> object(DateInterval)#7 (16) { ["y"]=> int(0) ["m"]=> int(0) ["d"]=> int(7) ["h"]=> int(0) ["i"]=> int(0) ["s"]=> int(0) ["f"]=> float(0) ["weekday"]=> int(0) ["weekday_behavior"]=> int(0) ["first_last_day_of"]=> int(0) ["invert"]=> int(0) ["days"]=> bool(false) ["special_type"]=> int(0) ["special_amount"]=> int(0) ["have_weekday_relative"]=> int(0) ["have_special_relative"]=> int(0) } ["recurrences"]=> int(0) ["include_start_date"]=> bool(false) } object(DateTime)#9 (3) { ["date"]=> string(26) "2012-07-08 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#10 (3) { ["date"]=> string(26) "2012-07-15 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#9 (3) { ["date"]=> string(26) "2012-07-22 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#10 (3) { ["date"]=> string(26) "2012-07-29 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.3.32 - 7.3.33, 8.0.13
object(DatePeriod)#4 (6) { ["start"]=> object(DateTime)#5 (3) { ["date"]=> string(26) "2012-07-01 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } ["current"]=> NULL ["end"]=> object(DateTime)#6 (3) { ["date"]=> string(26) "2012-07-31 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } ["interval"]=> object(DateInterval)#7 (16) { ["y"]=> int(0) ["m"]=> int(0) ["d"]=> int(7) ["h"]=> int(0) ["i"]=> int(0) ["s"]=> int(0) ["f"]=> float(0) ["weekday"]=> int(0) ["weekday_behavior"]=> int(0) ["first_last_day_of"]=> int(0) ["invert"]=> int(0) ["days"]=> bool(false) ["special_type"]=> int(0) ["special_amount"]=> int(0) ["have_weekday_relative"]=> int(0) ["have_special_relative"]=> int(0) } ["recurrences"]=> int(0) ["include_start_date"]=> bool(false) } object(DateTime)#9 (3) { ["date"]=> string(26) "2012-07-08 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#10 (3) { ["date"]=> string(26) "2012-07-15 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#9 (3) { ["date"]=> string(26) "2012-07-22 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#10 (3) { ["date"]=> string(26) "2012-07-29 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" }
Output for 5.4.30 - 5.4.45, 5.5.24 - 5.5.35, 5.6.7 - 5.6.28, 7.0.0 - 7.0.20
object(DatePeriod)#4 (6) { ["start"]=> object(DateTime)#5 (3) { ["date"]=> string(26) "2012-07-01 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } ["current"]=> NULL ["end"]=> object(DateTime)#6 (3) { ["date"]=> string(26) "2012-07-31 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } ["interval"]=> object(DateInterval)#7 (15) { ["y"]=> int(0) ["m"]=> int(0) ["d"]=> int(7) ["h"]=> int(0) ["i"]=> int(0) ["s"]=> int(0) ["weekday"]=> int(0) ["weekday_behavior"]=> int(0) ["first_last_day_of"]=> int(0) ["invert"]=> int(0) ["days"]=> bool(false) ["special_type"]=> int(0) ["special_amount"]=> int(0) ["have_weekday_relative"]=> int(0) ["have_special_relative"]=> int(0) } ["recurrences"]=> int(0) ["include_start_date"]=> bool(false) } object(DateTime)#9 (3) { ["date"]=> string(26) "2012-07-08 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#10 (3) { ["date"]=> string(26) "2012-07-15 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#9 (3) { ["date"]=> string(26) "2012-07-22 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#10 (3) { ["date"]=> string(26) "2012-07-29 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.4.17 - 5.4.29
object(DatePeriod)#4 (6) { ["start"]=> object(DateTime)#5 (3) { ["date"]=> string(19) "2012-07-01 00:00:00" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } ["current"]=> NULL ["end"]=> object(DateTime)#6 (3) { ["date"]=> string(19) "2012-07-31 00:00:00" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } ["interval"]=> object(DateInterval)#7 (15) { ["y"]=> int(0) ["m"]=> int(0) ["d"]=> int(7) ["h"]=> int(0) ["i"]=> int(0) ["s"]=> int(0) ["weekday"]=> int(0) ["weekday_behavior"]=> int(0) ["first_last_day_of"]=> int(0) ["invert"]=> int(0) ["days"]=> bool(false) ["special_type"]=> int(0) ["special_amount"]=> int(0) ["have_weekday_relative"]=> int(0) ["have_special_relative"]=> int(0) } ["recurrences"]=> int(0) ["include_start_date"]=> bool(false) } object(DateTime)#9 (3) { ["date"]=> string(19) "2012-07-08 00:00:00" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#10 (3) { ["date"]=> string(19) "2012-07-15 00:00:00" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#9 (3) { ["date"]=> string(19) "2012-07-22 00:00:00" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#10 (3) { ["date"]=> string(19) "2012-07-29 00:00:00" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.4.2 - 5.4.16
object(DatePeriod)#4 (0) { } object(DateTime)#6 (3) { ["date"]=> string(19) "2012-07-08 00:00:00" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#7 (3) { ["date"]=> string(19) "2012-07-15 00:00:00" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#6 (3) { ["date"]=> string(19) "2012-07-22 00:00:00" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#7 (3) { ["date"]=> string(19) "2012-07-29 00:00:00" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }

preferences:
214.75 ms | 403 KiB | 227 Q