3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $date = new DateTime(); $date->modify('+1 year'); $dateBegin = new DateTime($date->format('Y-m-d')); $date->modify('+8 day'); $dateEnd = new DateTime($date->format('Y-m-d')); $dateInterval = \DateInterval::createFromDateString('1 day'); $daterange = new \DatePeriod($dateBegin, $dateInterval, $dateEnd); $return['days'] = array(); foreach($daterange as $date){ $return['days'][] = $date->format("Y-m-d"); } var_dump($return);
based on TNvtV
Output for 5.6.28, 7.0.20 - 7.2.0
array(1) { ["days"]=> array(8) { [0]=> string(10) "2016-09-05" [1]=> string(10) "2016-09-06" [2]=> string(10) "2016-09-07" [3]=> string(10) "2016-09-08" [4]=> string(10) "2016-09-09" [5]=> string(10) "2016-09-10" [6]=> string(10) "2016-09-11" [7]=> string(10) "2016-09-12" } }
Output for 7.0.6
array(1) { ["days"]=> array(8) { [0]=> string(10) "2017-05-03" [1]=> string(10) "2017-05-04" [2]=> string(10) "2017-05-05" [3]=> string(10) "2017-05-06" [4]=> string(10) "2017-05-07" [5]=> string(10) "2017-05-08" [6]=> string(10) "2017-05-09" [7]=> string(10) "2017-05-10" } }
Output for 5.6.14, 7.0.5
array(1) { ["days"]=> array(8) { [0]=> string(10) "2017-04-02" [1]=> string(10) "2017-04-03" [2]=> string(10) "2017-04-04" [3]=> string(10) "2017-04-05" [4]=> string(10) "2017-04-06" [5]=> string(10) "2017-04-07" [6]=> string(10) "2017-04-08" [7]=> string(10) "2017-04-09" } }
Output for 7.0.4
array(1) { ["days"]=> array(8) { [0]=> string(10) "2017-03-10" [1]=> string(10) "2017-03-11" [2]=> string(10) "2017-03-12" [3]=> string(10) "2017-03-13" [4]=> string(10) "2017-03-14" [5]=> string(10) "2017-03-15" [6]=> string(10) "2017-03-16" [7]=> string(10) "2017-03-17" } }
Output for 7.0.3
array(1) { ["days"]=> array(8) { [0]=> string(10) "2017-03-18" [1]=> string(10) "2017-03-19" [2]=> string(10) "2017-03-20" [3]=> string(10) "2017-03-21" [4]=> string(10) "2017-03-22" [5]=> string(10) "2017-03-23" [6]=> string(10) "2017-03-24" [7]=> string(10) "2017-03-25" } }
Output for 7.0.2
array(1) { ["days"]=> array(8) { [0]=> string(10) "2017-03-22" [1]=> string(10) "2017-03-23" [2]=> string(10) "2017-03-24" [3]=> string(10) "2017-03-25" [4]=> string(10) "2017-03-26" [5]=> string(10) "2017-03-27" [6]=> string(10) "2017-03-28" [7]=> string(10) "2017-03-29" } }
Output for 7.0.1
array(1) { ["days"]=> array(8) { [0]=> string(10) "2017-03-23" [1]=> string(10) "2017-03-24" [2]=> string(10) "2017-03-25" [3]=> string(10) "2017-03-26" [4]=> string(10) "2017-03-27" [5]=> string(10) "2017-03-28" [6]=> string(10) "2017-03-29" [7]=> string(10) "2017-03-30" } }
Output for 7.0.0
array(1) { ["days"]=> array(8) { [0]=> string(10) "2017-03-26" [1]=> string(10) "2017-03-27" [2]=> string(10) "2017-03-28" [3]=> string(10) "2017-03-29" [4]=> string(10) "2017-03-30" [5]=> string(10) "2017-03-31" [6]=> string(10) "2017-04-01" [7]=> string(10) "2017-04-02" } }
Output for 5.6.21
array(1) { ["days"]=> array(8) { [0]=> string(10) "2017-05-02" [1]=> string(10) "2017-05-03" [2]=> string(10) "2017-05-04" [3]=> string(10) "2017-05-05" [4]=> string(10) "2017-05-06" [5]=> string(10) "2017-05-07" [6]=> string(10) "2017-05-08" [7]=> string(10) "2017-05-09" } }
Output for 5.6.20
array(1) { ["days"]=> array(8) { [0]=> string(10) "2017-04-09" [1]=> string(10) "2017-04-10" [2]=> string(10) "2017-04-11" [3]=> string(10) "2017-04-12" [4]=> string(10) "2017-04-13" [5]=> string(10) "2017-04-14" [6]=> string(10) "2017-04-15" [7]=> string(10) "2017-04-16" } }
Output for 5.6.19
array(1) { ["days"]=> array(8) { [0]=> string(10) "2017-03-07" [1]=> string(10) "2017-03-08" [2]=> string(10) "2017-03-09" [3]=> string(10) "2017-03-10" [4]=> string(10) "2017-03-11" [5]=> string(10) "2017-03-12" [6]=> string(10) "2017-03-13" [7]=> string(10) "2017-03-14" } }
Output for 5.6.18
array(1) { ["days"]=> array(8) { [0]=> string(10) "2017-03-14" [1]=> string(10) "2017-03-15" [2]=> string(10) "2017-03-16" [3]=> string(10) "2017-03-17" [4]=> string(10) "2017-03-18" [5]=> string(10) "2017-03-19" [6]=> string(10) "2017-03-20" [7]=> string(10) "2017-03-21" } }
Output for 5.6.17
array(1) { ["days"]=> array(8) { [0]=> string(10) "2017-03-19" [1]=> string(10) "2017-03-20" [2]=> string(10) "2017-03-21" [3]=> string(10) "2017-03-22" [4]=> string(10) "2017-03-23" [5]=> string(10) "2017-03-24" [6]=> string(10) "2017-03-25" [7]=> string(10) "2017-03-26" } }
Output for 5.6.16
array(1) { ["days"]=> array(8) { [0]=> string(10) "2017-03-27" [1]=> string(10) "2017-03-28" [2]=> string(10) "2017-03-29" [3]=> string(10) "2017-03-30" [4]=> string(10) "2017-03-31" [5]=> string(10) "2017-04-01" [6]=> string(10) "2017-04-02" [7]=> string(10) "2017-04-03" } }
Output for 5.6.15
array(1) { ["days"]=> array(8) { [0]=> string(10) "2017-03-28" [1]=> string(10) "2017-03-29" [2]=> string(10) "2017-03-30" [3]=> string(10) "2017-03-31" [4]=> string(10) "2017-04-01" [5]=> string(10) "2017-04-02" [6]=> string(10) "2017-04-03" [7]=> string(10) "2017-04-04" } }
Output for 5.6.13
array(1) { ["days"]=> array(8) { [0]=> string(10) "2017-04-15" [1]=> string(10) "2017-04-16" [2]=> string(10) "2017-04-17" [3]=> string(10) "2017-04-18" [4]=> string(10) "2017-04-19" [5]=> string(10) "2017-04-20" [6]=> string(10) "2017-04-21" [7]=> string(10) "2017-04-22" } }
Output for 5.6.12
array(1) { ["days"]=> array(8) { [0]=> string(10) "2017-04-19" [1]=> string(10) "2017-04-20" [2]=> string(10) "2017-04-21" [3]=> string(10) "2017-04-22" [4]=> string(10) "2017-04-23" [5]=> string(10) "2017-04-24" [6]=> string(10) "2017-04-25" [7]=> string(10) "2017-04-26" } }
Output for 5.6.11
array(1) { ["days"]=> array(8) { [0]=> string(10) "2017-04-23" [1]=> string(10) "2017-04-24" [2]=> string(10) "2017-04-25" [3]=> string(10) "2017-04-26" [4]=> string(10) "2017-04-27" [5]=> string(10) "2017-04-28" [6]=> string(10) "2017-04-29" [7]=> string(10) "2017-04-30" } }
Output for 5.6.10
array(1) { ["days"]=> array(8) { [0]=> string(10) "2017-04-25" [1]=> string(10) "2017-04-26" [2]=> string(10) "2017-04-27" [3]=> string(10) "2017-04-28" [4]=> string(10) "2017-04-29" [5]=> string(10) "2017-04-30" [6]=> string(10) "2017-05-01" [7]=> string(10) "2017-05-02" } }
Output for 5.6.9
array(1) { ["days"]=> array(8) { [0]=> string(10) "2017-04-27" [1]=> string(10) "2017-04-28" [2]=> string(10) "2017-04-29" [3]=> string(10) "2017-04-30" [4]=> string(10) "2017-05-01" [5]=> string(10) "2017-05-02" [6]=> string(10) "2017-05-03" [7]=> string(10) "2017-05-04" } }
Output for 5.6.8
array(1) { ["days"]=> array(8) { [0]=> string(10) "2017-04-29" [1]=> string(10) "2017-04-30" [2]=> string(10) "2017-05-01" [3]=> string(10) "2017-05-02" [4]=> string(10) "2017-05-03" [5]=> string(10) "2017-05-04" [6]=> string(10) "2017-05-05" [7]=> string(10) "2017-05-06" } }
Output for 5.6.7
array(1) { ["days"]=> array(8) { [0]=> string(10) "2017-05-25" [1]=> string(10) "2017-05-26" [2]=> string(10) "2017-05-27" [3]=> string(10) "2017-05-28" [4]=> string(10) "2017-05-29" [5]=> string(10) "2017-05-30" [6]=> string(10) "2017-05-31" [7]=> string(10) "2017-06-01" } }
Output for 5.5.35
array(1) { ["days"]=> array(8) { [0]=> string(10) "2017-05-22" [1]=> string(10) "2017-05-23" [2]=> string(10) "2017-05-24" [3]=> string(10) "2017-05-25" [4]=> string(10) "2017-05-26" [5]=> string(10) "2017-05-27" [6]=> string(10) "2017-05-28" [7]=> string(10) "2017-05-29" } }
Output for 5.5.34
array(1) { ["days"]=> array(8) { [0]=> string(10) "2017-04-10" [1]=> string(10) "2017-04-11" [2]=> string(10) "2017-04-12" [3]=> string(10) "2017-04-13" [4]=> string(10) "2017-04-14" [5]=> string(10) "2017-04-15" [6]=> string(10) "2017-04-16" [7]=> string(10) "2017-04-17" } }
Output for 5.5.33
array(1) { ["days"]=> array(8) { [0]=> string(10) "2017-03-08" [1]=> string(10) "2017-03-09" [2]=> string(10) "2017-03-10" [3]=> string(10) "2017-03-11" [4]=> string(10) "2017-03-12" [5]=> string(10) "2017-03-13" [6]=> string(10) "2017-03-14" [7]=> string(10) "2017-03-15" } }
Output for 5.5.32
array(1) { ["days"]=> array(8) { [0]=> string(10) "2017-03-16" [1]=> string(10) "2017-03-17" [2]=> string(10) "2017-03-18" [3]=> string(10) "2017-03-19" [4]=> string(10) "2017-03-20" [5]=> string(10) "2017-03-21" [6]=> string(10) "2017-03-22" [7]=> string(10) "2017-03-23" } }
Output for 5.5.31
array(1) { ["days"]=> array(8) { [0]=> string(10) "2017-03-20" [1]=> string(10) "2017-03-21" [2]=> string(10) "2017-03-22" [3]=> string(10) "2017-03-23" [4]=> string(10) "2017-03-24" [5]=> string(10) "2017-03-25" [6]=> string(10) "2017-03-26" [7]=> string(10) "2017-03-27" } }
Output for 5.5.30
array(1) { ["days"]=> array(8) { [0]=> string(10) "2017-03-31" [1]=> string(10) "2017-04-01" [2]=> string(10) "2017-04-02" [3]=> string(10) "2017-04-03" [4]=> string(10) "2017-04-04" [5]=> string(10) "2017-04-05" [6]=> string(10) "2017-04-06" [7]=> string(10) "2017-04-07" } }
Output for 5.5.29
array(1) { ["days"]=> array(8) { [0]=> string(10) "2017-04-16" [1]=> string(10) "2017-04-17" [2]=> string(10) "2017-04-18" [3]=> string(10) "2017-04-19" [4]=> string(10) "2017-04-20" [5]=> string(10) "2017-04-21" [6]=> string(10) "2017-04-22" [7]=> string(10) "2017-04-23" } }
Output for 5.5.28
array(1) { ["days"]=> array(8) { [0]=> string(10) "2017-04-20" [1]=> string(10) "2017-04-21" [2]=> string(10) "2017-04-22" [3]=> string(10) "2017-04-23" [4]=> string(10) "2017-04-24" [5]=> string(10) "2017-04-25" [6]=> string(10) "2017-04-26" [7]=> string(10) "2017-04-27" } }
Output for 5.5.27
array(1) { ["days"]=> array(8) { [0]=> string(10) "2017-04-21" [1]=> string(10) "2017-04-22" [2]=> string(10) "2017-04-23" [3]=> string(10) "2017-04-24" [4]=> string(10) "2017-04-25" [5]=> string(10) "2017-04-26" [6]=> string(10) "2017-04-27" [7]=> string(10) "2017-04-28" } }
Output for 5.5.26
array(1) { ["days"]=> array(8) { [0]=> string(10) "2017-04-26" [1]=> string(10) "2017-04-27" [2]=> string(10) "2017-04-28" [3]=> string(10) "2017-04-29" [4]=> string(10) "2017-04-30" [5]=> string(10) "2017-05-01" [6]=> string(10) "2017-05-02" [7]=> string(10) "2017-05-03" } }
Output for 5.5.25
array(1) { ["days"]=> array(8) { [0]=> string(10) "2017-04-28" [1]=> string(10) "2017-04-29" [2]=> string(10) "2017-04-30" [3]=> string(10) "2017-05-01" [4]=> string(10) "2017-05-02" [5]=> string(10) "2017-05-03" [6]=> string(10) "2017-05-04" [7]=> string(10) "2017-05-05" } }
Output for 5.5.24
array(1) { ["days"]=> array(8) { [0]=> string(10) "2017-05-23" [1]=> string(10) "2017-05-24" [2]=> string(10) "2017-05-25" [3]=> string(10) "2017-05-26" [4]=> string(10) "2017-05-27" [5]=> string(10) "2017-05-28" [6]=> string(10) "2017-05-29" [7]=> string(10) "2017-05-30" } }
Output for 5.3.0 - 5.4.45
array(1) { ["days"]=> array(8) { [0]=> string(10) "2016-10-12" [1]=> string(10) "2016-10-13" [2]=> string(10) "2016-10-14" [3]=> string(10) "2016-10-15" [4]=> string(10) "2016-10-16" [5]=> string(10) "2016-10-17" [6]=> string(10) "2016-10-18" [7]=> string(10) "2016-10-19" } }
Output for 5.2.0 - 5.2.17
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/4ZvZR on line 7 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/4ZvZR on line 8 Fatal error: Class 'DateInterval' not found in /in/4ZvZR on line 7
Process exited with code 255.
Output for 5.0.0 - 5.1.6
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/4ZvZR on line 7 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/4ZvZR on line 8 Fatal error: Class 'DateTime' not found in /in/4ZvZR on line 2
Process exited with code 255.
Output for 4.3.2 - 4.4.9
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/4ZvZR on line 7 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/4ZvZR on line 8 Fatal error: Cannot instantiate non-existent class: datetime in /in/4ZvZR on line 2
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/4ZvZR on line 7 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/4ZvZR on line 8 Fatal error: Cannot instantiate non-existent class: datetime in /in/4ZvZR on line 2