3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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 7.1.0 - 7.2.0
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 5.4.30 - 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.3.27 - 5.3.29, 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.3.18 - 5.3.26, 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" }