3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $start_date = '2014-3-19'; $end_date = '2014-5-19'; $begin = new DateTime( $start_date ); $end = new DateTime(date("Y-m-d",strtotime("+1 day", strtotime($end_date)))); while($begin < $end) { $period[] = $begin->format('Y-m-d'); $begin->modify('+1 day'); } var_dump($period);
Output for 5.2.2 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
array(62) { [0]=> string(10) "2014-03-19" [1]=> string(10) "2014-03-20" [2]=> string(10) "2014-03-21" [3]=> string(10) "2014-03-22" [4]=> string(10) "2014-03-23" [5]=> string(10) "2014-03-24" [6]=> string(10) "2014-03-25" [7]=> string(10) "2014-03-26" [8]=> string(10) "2014-03-27" [9]=> string(10) "2014-03-28" [10]=> string(10) "2014-03-29" [11]=> string(10) "2014-03-30" [12]=> string(10) "2014-03-31" [13]=> string(10) "2014-04-01" [14]=> string(10) "2014-04-02" [15]=> string(10) "2014-04-03" [16]=> string(10) "2014-04-04" [17]=> string(10) "2014-04-05" [18]=> string(10) "2014-04-06" [19]=> string(10) "2014-04-07" [20]=> string(10) "2014-04-08" [21]=> string(10) "2014-04-09" [22]=> string(10) "2014-04-10" [23]=> string(10) "2014-04-11" [24]=> string(10) "2014-04-12" [25]=> string(10) "2014-04-13" [26]=> string(10) "2014-04-14" [27]=> string(10) "2014-04-15" [28]=> string(10) "2014-04-16" [29]=> string(10) "2014-04-17" [30]=> string(10) "2014-04-18" [31]=> string(10) "2014-04-19" [32]=> string(10) "2014-04-20" [33]=> string(10) "2014-04-21" [34]=> string(10) "2014-04-22" [35]=> string(10) "2014-04-23" [36]=> string(10) "2014-04-24" [37]=> string(10) "2014-04-25" [38]=> string(10) "2014-04-26" [39]=> string(10) "2014-04-27" [40]=> string(10) "2014-04-28" [41]=> string(10) "2014-04-29" [42]=> string(10) "2014-04-30" [43]=> string(10) "2014-05-01" [44]=> string(10) "2014-05-02" [45]=> string(10) "2014-05-03" [46]=> string(10) "2014-05-04" [47]=> string(10) "2014-05-05" [48]=> string(10) "2014-05-06" [49]=> string(10) "2014-05-07" [50]=> string(10) "2014-05-08" [51]=> string(10) "2014-05-09" [52]=> string(10) "2014-05-10" [53]=> string(10) "2014-05-11" [54]=> string(10) "2014-05-12" [55]=> string(10) "2014-05-13" [56]=> string(10) "2014-05-14" [57]=> string(10) "2014-05-15" [58]=> string(10) "2014-05-16" [59]=> string(10) "2014-05-17" [60]=> string(10) "2014-05-18" [61]=> string(10) "2014-05-19" }
Output for 5.2.0 - 5.2.1
Notice: Undefined variable: period in /in/WLu4M on line 13 NULL
Output for 5.0.0 - 5.1.6
Fatal error: Class 'DateTime' not found in /in/WLu4M on line 6
Process exited with code 255.
Output for 4.3.2 - 4.4.9
Fatal error: Cannot instantiate non-existent class: datetime in /in/WLu4M on line 6
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Cannot instantiate non-existent class: datetime in /in/WLu4M on line 6