3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function getDay($day) { $days = array('Monday' => 1, 'Tuesday' => 2, 'Wednesday' => 3, 'Thursday' => 4, 'Friday' => 5, 'Saturday' => 6, 'Sunday' => 7); $today = new \DateTime(); $today->setISODate($today->format('o'), $today->format('W'), $days[ucfirst($day)]); return $today; } var_dump(getDay('Monday')->format('l dS F Y')); var_dump(getDay('Friday')->format('l dS F Y'));
Output for 5.6.28, 7.0.14 - 7.1.0
string(21) "Monday 01st June 2015" string(21) "Friday 05th June 2015"
Output for 5.6.21, 7.0.6
string(20) "Monday 02nd May 2016" string(20) "Friday 06th May 2016"
Output for 5.5.0 - 5.5.34, 5.6.0 - 5.6.20, 7.0.0 - 7.0.5
string(22) "Monday 11th April 2016" string(22) "Friday 15th April 2016"
Output for 5.5.35
string(20) "Monday 16th May 2016" string(20) "Friday 20th May 2016"
Output for 5.4.0 - 5.4.45
Fatal error: Uncaught exception 'Exception' with message 'DateTime::__construct(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone.' in /in/kEFCO:6 Stack trace: #0 /in/kEFCO(6): DateTime->__construct() #1 /in/kEFCO(11): getDay('Monday') #2 {main} thrown in /in/kEFCO on line 6
Process exited with code 255.
Output for 5.3.0 - 5.3.29
Fatal error: Uncaught exception 'Exception' with message 'DateTime::__construct(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Berlin' for 'CEST/2.0/DST' instead' in /in/kEFCO:6 Stack trace: #0 /in/kEFCO(6): DateTime->__construct() #1 /in/kEFCO(11): getDay('Monday') #2 {main} thrown in /in/kEFCO on line 6
Process exited with code 255.
Output for 5.2.3 - 5.2.17
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/kEFCO on line 6 string(22) "Monday 11th April 2016" string(22) "Friday 15th April 2016"
Output for 5.2.0 - 5.2.2
<br /> <b>Warning</b>: Unexpected character in input: '\' (ASCII=92) state=1 in <b>/in/kEFCO</b> on line <b>6</b><br /> string(22) "Monday 11th April 2016" string(22) "Friday 15th April 2016"
Output for 5.0.0 - 5.1.6
<br /> <b>Warning</b>: Unexpected character in input: '\' (ASCII=92) state=1 in <b>/in/kEFCO</b> on line <b>6</b><br /> <br /> <b>Fatal error</b>: Class 'DateTime' not found in <b>/in/kEFCO</b> on line <b>6</b><br />
Process exited with code 255.
Output for 4.4.2 - 4.4.9
<br /> <b>Warning</b>: Unexpected character in input: '\' (ASCII=92) state=1 in <b>/in/kEFCO</b> on line <b>6</b><br /> <br /> <b>Parse error</b>: syntax error, unexpected T_OBJECT_OPERATOR in <b>/in/kEFCO</b> on line <b>11</b><br />
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
<br /> <b>Warning</b>: Unexpected character in input: '\' (ASCII=92) state=1 in <b>/in/kEFCO</b> on line <b>6</b><br /> <br /> <b>Parse error</b>: parse error, unexpected T_OBJECT_OPERATOR in <b>/in/kEFCO</b> on line <b>11</b><br />
Process exited with code 255.
Output for 4.3.2 - 4.3.4
<br /> <b>Warning</b>: Unexpected character in input: '\' (ASCII=92) state=1 in <b>/in/kEFCO</b> on line <b>6</b><br /> <br /> <b>Parse error</b>: parse error in <b>/in/kEFCO</b> on line <b>11</b><br />
Process exited with code 255.