3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function getWeekDate($week, $year) { date_default_timezone_set('Asia/Kuala_Lumpur'); $time = strtotime("1 January $year", time()); $day = date('w', $time); $time += ((7*$week)+1-$day)*24*3600; $return[0] = date('Y-n-j', $time); $time += 1*24*3600; $return[1] = date('Y-n-j', $time); $time += 1*24*3600; $return[2] = date('Y-n-j', $time); $time += 1*24*3600; $return[3] = date('Y-n-j', $time); $time += 1*24*3600; $return[4] = date('Y-n-j', $time); $time += 1*24*3600; $return[5] = date('Y-n-j', $time); $time += 1*24*3600; $return[6] = date('Y-n-j', $time); return $return; } $lol = getWeekDate(52, 2013); echo "Isnin ".$lol[0]."<br/>"; echo "Selasa ".$lol[1]."<br/>"; echo "Rabu ".$lol[2]."<br/>"; echo "Khamis ".$lol[3]."<br/>"; echo "Jumaat ".$lol[4]."<br/>"; echo "Sabtu ".$lol[5]."<br/>"; echo "Ahad ".$lol[6]; ?>
Output for 5.1.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
Isnin 2013-12-30<br/>Selasa 2013-12-31<br/>Rabu 2014-1-1<br/>Khamis 2014-1-2<br/>Jumaat 2014-1-3<br/>Sabtu 2014-1-4<br/>Ahad 2014-1-5
Output for 5.0.0 - 5.0.5
Fatal error: Call to undefined function date_default_timezone_set() in /in/EV0vK on line 5
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: date_default_timezone_set() in /in/EV0vK on line 5
Process exited with code 255.
Output for 4.3.2 - 4.4.4
Fatal error: Call to undefined function: date_default_timezone_set() in /in/EV0vK on line 5
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: date_default_timezone_set() in /in/EV0vK on line 5