3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function daysInWeek($weekNum) { $result = array(); $datetime = new DateTime(); $datetime->setISODate((int)$datetime->format('o'), $weekNum, 1); $dateTime->setTime(0, 0, 0); $interval = new DateInterval('P1D'); $week = new DatePeriod($datetime, $interval, 6); foreach($week as $day){ $result[] = $day->format('D d m Y H:i:s'); } return $result; } var_dump(daysInWeek(24)); //and the difficult ones:- var_dump(daysInWeek(1)); var_dump(daysInWeek(53));
Output for 7.0.5 - 7.1.0
Notice: Undefined variable: dateTime in /in/eGjPY on line 7 Fatal error: Uncaught Error: Call to a member function setTime() on null in /in/eGjPY:7 Stack trace: #0 /in/eGjPY(17): daysInWeek(24) #1 {main} thrown in /in/eGjPY on line 7
Process exited with code 255.
Output for 7.0.0 - 7.0.4
Notice: Undefined variable: dateTime in /in/eGjPY on line 7 Fatal error: Uncaught Error: Call to a member function setTime() on unknown in /in/eGjPY:7 Stack trace: #0 /in/eGjPY(17): daysInWeek(24) #1 {main} thrown in /in/eGjPY on line 7
Process exited with code 255.
Output for hhvm-3.10.0 - 3.12.0
Notice: Undefined variable: dateTime in /in/eGjPY on line 7 Fatal error: Uncaught exception 'BadMethodCallException' with message 'Call to a member function setTime() on a non-object (null)' in /in/eGjPY:7 Stack trace: #0 /in/eGjPY(17): daysInWeek() #1 {main}
Process exited with code 255.
Output for 5.6.7 - 5.6.28
Notice: Undefined variable: dateTime in /in/eGjPY on line 7 Fatal error: Call to a member function setTime() on null in /in/eGjPY on line 7
Process exited with code 255.
Output for 5.2.0 - 5.5.35
Notice: Undefined variable: dateTime in /in/eGjPY on line 7 Fatal error: Call to a member function setTime() on a non-object in /in/eGjPY on line 7
Process exited with code 255.
Output for 5.0.0 - 5.1.6
Fatal error: Class 'DateTime' not found in /in/eGjPY 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/eGjPY 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/eGjPY on line 5