3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $start = new DateTime('2014-01-01'); $end = new DateTime('2015-01-01'); $weeks = array(); while ($start < $end) { $weeks[] = $start->format('d-m-Y'); $start->modify('+1 week'); } print_r($weeks);
Output for 5.2.2 - 7.1.0
Array ( [0] => 01-01-2014 [1] => 08-01-2014 [2] => 15-01-2014 [3] => 22-01-2014 [4] => 29-01-2014 [5] => 05-02-2014 [6] => 12-02-2014 [7] => 19-02-2014 [8] => 26-02-2014 [9] => 05-03-2014 [10] => 12-03-2014 [11] => 19-03-2014 [12] => 26-03-2014 [13] => 02-04-2014 [14] => 09-04-2014 [15] => 16-04-2014 [16] => 23-04-2014 [17] => 30-04-2014 [18] => 07-05-2014 [19] => 14-05-2014 [20] => 21-05-2014 [21] => 28-05-2014 [22] => 04-06-2014 [23] => 11-06-2014 [24] => 18-06-2014 [25] => 25-06-2014 [26] => 02-07-2014 [27] => 09-07-2014 [28] => 16-07-2014 [29] => 23-07-2014 [30] => 30-07-2014 [31] => 06-08-2014 [32] => 13-08-2014 [33] => 20-08-2014 [34] => 27-08-2014 [35] => 03-09-2014 [36] => 10-09-2014 [37] => 17-09-2014 [38] => 24-09-2014 [39] => 01-10-2014 [40] => 08-10-2014 [41] => 15-10-2014 [42] => 22-10-2014 [43] => 29-10-2014 [44] => 05-11-2014 [45] => 12-11-2014 [46] => 19-11-2014 [47] => 26-11-2014 [48] => 03-12-2014 [49] => 10-12-2014 [50] => 17-12-2014 [51] => 24-12-2014 [52] => 31-12-2014 )
Output for 5.2.0 - 5.2.1
Array ( )
Output for 5.0.0 - 5.1.6
Fatal error: Class 'DateTime' not found in /in/WTtHb on line 2
Process exited with code 255.
Output for 4.3.2 - 4.4.9
Fatal error: Cannot instantiate non-existent class: datetime in /in/WTtHb on line 2
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Cannot instantiate non-existent class: datetime in /in/WTtHb on line 2