3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function daysInWeek($weekNum) { $result = array(); $datetime = new DateTime('00:00:00'); $datetime->setISODate((int)$datetime->format('o'), $weekNum, 1); $interval = new DateInterval('P7D'); $week = new DatePeriod($datetime, $interval, 52); foreach($week as $day){ $result[] = $day->format('D d m Y H:i:s'); } return $result; } //and the difficult ones:- var_dump(daysInWeek(1));
Output for 5.6.28, 7.0.14 - 7.1.0
array(53) { [0]=> string(23) "Mon 30 12 2013 00:00:00" [1]=> string(23) "Mon 06 01 2014 00:00:00" [2]=> string(23) "Mon 13 01 2014 00:00:00" [3]=> string(23) "Mon 20 01 2014 00:00:00" [4]=> string(23) "Mon 27 01 2014 00:00:00" [5]=> string(23) "Mon 03 02 2014 00:00:00" [6]=> string(23) "Mon 10 02 2014 00:00:00" [7]=> string(23) "Mon 17 02 2014 00:00:00" [8]=> string(23) "Mon 24 02 2014 00:00:00" [9]=> string(23) "Mon 03 03 2014 00:00:00" [10]=> string(23) "Mon 10 03 2014 00:00:00" [11]=> string(23) "Mon 17 03 2014 00:00:00" [12]=> string(23) "Mon 24 03 2014 00:00:00" [13]=> string(23) "Mon 31 03 2014 00:00:00" [14]=> string(23) "Mon 07 04 2014 00:00:00" [15]=> string(23) "Mon 14 04 2014 00:00:00" [16]=> string(23) "Mon 21 04 2014 00:00:00" [17]=> string(23) "Mon 28 04 2014 00:00:00" [18]=> string(23) "Mon 05 05 2014 00:00:00" [19]=> string(23) "Mon 12 05 2014 00:00:00" [20]=> string(23) "Mon 19 05 2014 00:00:00" [21]=> string(23) "Mon 26 05 2014 00:00:00" [22]=> string(23) "Mon 02 06 2014 00:00:00" [23]=> string(23) "Mon 09 06 2014 00:00:00" [24]=> string(23) "Mon 16 06 2014 00:00:00" [25]=> string(23) "Mon 23 06 2014 00:00:00" [26]=> string(23) "Mon 30 06 2014 00:00:00" [27]=> string(23) "Mon 07 07 2014 00:00:00" [28]=> string(23) "Mon 14 07 2014 00:00:00" [29]=> string(23) "Mon 21 07 2014 00:00:00" [30]=> string(23) "Mon 28 07 2014 00:00:00" [31]=> string(23) "Mon 04 08 2014 00:00:00" [32]=> string(23) "Mon 11 08 2014 00:00:00" [33]=> string(23) "Mon 18 08 2014 00:00:00" [34]=> string(23) "Mon 25 08 2014 00:00:00" [35]=> string(23) "Mon 01 09 2014 00:00:00" [36]=> string(23) "Mon 08 09 2014 00:00:00" [37]=> string(23) "Mon 15 09 2014 00:00:00" [38]=> string(23) "Mon 22 09 2014 00:00:00" [39]=> string(23) "Mon 29 09 2014 00:00:00" [40]=> string(23) "Mon 06 10 2014 00:00:00" [41]=> string(23) "Mon 13 10 2014 00:00:00" [42]=> string(23) "Mon 20 10 2014 00:00:00" [43]=> string(23) "Mon 27 10 2014 00:00:00" [44]=> string(23) "Mon 03 11 2014 00:00:00" [45]=> string(23) "Mon 10 11 2014 00:00:00" [46]=> string(23) "Mon 17 11 2014 00:00:00" [47]=> string(23) "Mon 24 11 2014 00:00:00" [48]=> string(23) "Mon 01 12 2014 00:00:00" [49]=> string(23) "Mon 08 12 2014 00:00:00" [50]=> string(23) "Mon 15 12 2014 00:00:00" [51]=> string(23) "Mon 22 12 2014 00:00:00" [52]=> string(23) "Mon 29 12 2014 00:00:00" }
Output for 5.5.24 - 5.6.21, 7.0.0 - 7.0.6
array(53) { [0]=> string(23) "Mon 04 01 2016 00:00:00" [1]=> string(23) "Mon 11 01 2016 00:00:00" [2]=> string(23) "Mon 18 01 2016 00:00:00" [3]=> string(23) "Mon 25 01 2016 00:00:00" [4]=> string(23) "Mon 01 02 2016 00:00:00" [5]=> string(23) "Mon 08 02 2016 00:00:00" [6]=> string(23) "Mon 15 02 2016 00:00:00" [7]=> string(23) "Mon 22 02 2016 00:00:00" [8]=> string(23) "Mon 29 02 2016 00:00:00" [9]=> string(23) "Mon 07 03 2016 00:00:00" [10]=> string(23) "Mon 14 03 2016 00:00:00" [11]=> string(23) "Mon 21 03 2016 00:00:00" [12]=> string(23) "Mon 28 03 2016 00:00:00" [13]=> string(23) "Mon 04 04 2016 00:00:00" [14]=> string(23) "Mon 11 04 2016 00:00:00" [15]=> string(23) "Mon 18 04 2016 00:00:00" [16]=> string(23) "Mon 25 04 2016 00:00:00" [17]=> string(23) "Mon 02 05 2016 00:00:00" [18]=> string(23) "Mon 09 05 2016 00:00:00" [19]=> string(23) "Mon 16 05 2016 00:00:00" [20]=> string(23) "Mon 23 05 2016 00:00:00" [21]=> string(23) "Mon 30 05 2016 00:00:00" [22]=> string(23) "Mon 06 06 2016 00:00:00" [23]=> string(23) "Mon 13 06 2016 00:00:00" [24]=> string(23) "Mon 20 06 2016 00:00:00" [25]=> string(23) "Mon 27 06 2016 00:00:00" [26]=> string(23) "Mon 04 07 2016 00:00:00" [27]=> string(23) "Mon 11 07 2016 00:00:00" [28]=> string(23) "Mon 18 07 2016 00:00:00" [29]=> string(23) "Mon 25 07 2016 00:00:00" [30]=> string(23) "Mon 01 08 2016 00:00:00" [31]=> string(23) "Mon 08 08 2016 00:00:00" [32]=> string(23) "Mon 15 08 2016 00:00:00" [33]=> string(23) "Mon 22 08 2016 00:00:00" [34]=> string(23) "Mon 29 08 2016 00:00:00" [35]=> string(23) "Mon 05 09 2016 00:00:00" [36]=> string(23) "Mon 12 09 2016 00:00:00" [37]=> string(23) "Mon 19 09 2016 00:00:00" [38]=> string(23) "Mon 26 09 2016 00:00:00" [39]=> string(23) "Mon 03 10 2016 00:00:00" [40]=> string(23) "Mon 10 10 2016 00:00:00" [41]=> string(23) "Mon 17 10 2016 00:00:00" [42]=> string(23) "Mon 24 10 2016 00:00:00" [43]=> string(23) "Mon 31 10 2016 00:00:00" [44]=> string(23) "Mon 07 11 2016 00:00:00" [45]=> string(23) "Mon 14 11 2016 00:00:00" [46]=> string(23) "Mon 21 11 2016 00:00:00" [47]=> string(23) "Mon 28 11 2016 00:00:00" [48]=> string(23) "Mon 05 12 2016 00:00:00" [49]=> string(23) "Mon 12 12 2016 00:00:00" [50]=> string(23) "Mon 19 12 2016 00:00:00" [51]=> string(23) "Mon 26 12 2016 00:00:00" [52]=> string(23) "Mon 02 01 2017 00:00:00" }
Output for 5.3.0 - 5.4.45
array(53) { [0]=> string(23) "Mon 29 12 2014 00:00:00" [1]=> string(23) "Mon 05 01 2015 00:00:00" [2]=> string(23) "Mon 12 01 2015 00:00:00" [3]=> string(23) "Mon 19 01 2015 00:00:00" [4]=> string(23) "Mon 26 01 2015 00:00:00" [5]=> string(23) "Mon 02 02 2015 00:00:00" [6]=> string(23) "Mon 09 02 2015 00:00:00" [7]=> string(23) "Mon 16 02 2015 00:00:00" [8]=> string(23) "Mon 23 02 2015 00:00:00" [9]=> string(23) "Mon 02 03 2015 00:00:00" [10]=> string(23) "Mon 09 03 2015 00:00:00" [11]=> string(23) "Mon 16 03 2015 00:00:00" [12]=> string(23) "Mon 23 03 2015 00:00:00" [13]=> string(23) "Mon 30 03 2015 00:00:00" [14]=> string(23) "Mon 06 04 2015 00:00:00" [15]=> string(23) "Mon 13 04 2015 00:00:00" [16]=> string(23) "Mon 20 04 2015 00:00:00" [17]=> string(23) "Mon 27 04 2015 00:00:00" [18]=> string(23) "Mon 04 05 2015 00:00:00" [19]=> string(23) "Mon 11 05 2015 00:00:00" [20]=> string(23) "Mon 18 05 2015 00:00:00" [21]=> string(23) "Mon 25 05 2015 00:00:00" [22]=> string(23) "Mon 01 06 2015 00:00:00" [23]=> string(23) "Mon 08 06 2015 00:00:00" [24]=> string(23) "Mon 15 06 2015 00:00:00" [25]=> string(23) "Mon 22 06 2015 00:00:00" [26]=> string(23) "Mon 29 06 2015 00:00:00" [27]=> string(23) "Mon 06 07 2015 00:00:00" [28]=> string(23) "Mon 13 07 2015 00:00:00" [29]=> string(23) "Mon 20 07 2015 00:00:00" [30]=> string(23) "Mon 27 07 2015 00:00:00" [31]=> string(23) "Mon 03 08 2015 00:00:00" [32]=> string(23) "Mon 10 08 2015 00:00:00" [33]=> string(23) "Mon 17 08 2015 00:00:00" [34]=> string(23) "Mon 24 08 2015 00:00:00" [35]=> string(23) "Mon 31 08 2015 00:00:00" [36]=> string(23) "Mon 07 09 2015 00:00:00" [37]=> string(23) "Mon 14 09 2015 00:00:00" [38]=> string(23) "Mon 21 09 2015 00:00:00" [39]=> string(23) "Mon 28 09 2015 00:00:00" [40]=> string(23) "Mon 05 10 2015 00:00:00" [41]=> string(23) "Mon 12 10 2015 00:00:00" [42]=> string(23) "Mon 19 10 2015 00:00:00" [43]=> string(23) "Mon 26 10 2015 00:00:00" [44]=> string(23) "Mon 02 11 2015 00:00:00" [45]=> string(23) "Mon 09 11 2015 00:00:00" [46]=> string(23) "Mon 16 11 2015 00:00:00" [47]=> string(23) "Mon 23 11 2015 00:00:00" [48]=> string(23) "Mon 30 11 2015 00:00:00" [49]=> string(23) "Mon 07 12 2015 00:00:00" [50]=> string(23) "Mon 14 12 2015 00:00:00" [51]=> string(23) "Mon 21 12 2015 00:00:00" [52]=> string(23) "Mon 28 12 2015 00:00:00" }
Output for 5.2.0 - 5.2.17
Fatal error: Class 'DateInterval' not found in /in/WnZcI on line 7
Process exited with code 255.
Output for 5.0.0 - 5.1.6
Fatal error: Class 'DateTime' not found in /in/WnZcI on line 5
Process exited with code 255.
Output for 4.3.2 - 4.4.9
Fatal error: Cannot instantiate non-existent class: datetime in /in/WnZcI on line 5
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Cannot instantiate non-existent class: datetime in /in/WnZcI on line 5