3v4l.org

run code in 200+ 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')); var_dump(getDay('Friday')->format('l dS F Y'));
Output for 7.3.0rc4
object(DateTime)#1 (3) { ["date"]=> string(26) "2014-05-26 11:00:36.002816" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(20) "Friday 30th May 2014"
Output for 7.3.0rc3
object(DateTime)#1 (3) { ["date"]=> string(26) "2014-05-26 11:00:36.016225" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(20) "Friday 30th May 2014"
Output for 7.3.0beta1
object(DateTime)#1 (3) { ["date"]=> string(26) "2014-05-26 11:00:36.003614" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(20) "Friday 30th May 2014"
Output for 7.3.0alpha1
object(DateTime)#1 (3) { ["date"]=> string(26) "2014-05-26 11:00:36.003559" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(20) "Friday 30th May 2014"
Output for 7.2.8
object(DateTime)#1 (3) { ["date"]=> string(26) "2014-05-26 11:00:36.003288" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(20) "Friday 30th May 2014"
Output for 7.2.6
object(DateTime)#1 (3) { ["date"]=> string(26) "2014-05-26 11:00:36.003601" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(20) "Friday 30th May 2014"
Output for 7.2.0
object(DateTime)#1 (3) { ["date"]=> string(26) "2014-05-26 11:00:36.005682" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(20) "Friday 30th May 2014"
Output for 7.1.20
object(DateTime)#1 (3) { ["date"]=> string(26) "2014-05-26 11:00:36.003483" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(20) "Friday 30th May 2014"
Output for 7.1.10
object(DateTime)#1 (3) { ["date"]=> string(26) "2014-05-26 11:00:36.003595" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(20) "Friday 30th May 2014"
Output for 7.1.7
object(DateTime)#1 (3) { ["date"]=> string(26) "2014-05-26 11:00:36.003693" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(20) "Friday 30th May 2014"
Output for 7.1.6
object(DateTime)#1 (3) { ["date"]=> string(26) "2014-05-26 11:00:36.006415" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(20) "Friday 30th May 2014"
Output for 7.1.5
object(DateTime)#1 (3) { ["date"]=> string(26) "2014-05-26 11:00:36.010450" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(20) "Friday 30th May 2014"
Output for 7.1.0
object(DateTime)#1 (3) { ["date"]=> string(26) "2014-05-26 11:00:36.006370" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(20) "Friday 30th May 2014"
Output for 5.4.30 - 5.4.45, 5.5.14 - 7.0.20
object(DateTime)#1 (3) { ["date"]=> string(26) "2014-05-26 11:00:36.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(20) "Friday 30th May 2014"
Output for 5.3.0 - 5.4.29, 5.5.0 - 5.5.13
object(DateTime)#1 (3) { ["date"]=> string(19) "2014-05-26 11:00:36" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(20) "Friday 30th May 2014"
Output for 5.2.0 - 5.2.17
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/PcXIW on line 6 object(DateTime)#1 (0) { } string(20) "Friday 30th May 2014"
Output for 5.0.0 - 5.1.6
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/PcXIW on line 6 Fatal error: Class 'DateTime' not found in /in/PcXIW on line 6
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/PcXIW on line 6 Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /in/PcXIW on line 12
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/PcXIW on line 6 Parse error: parse error, unexpected T_OBJECT_OPERATOR in /in/PcXIW on line 12
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/PcXIW on line 6 Parse error: parse error in /in/PcXIW on line 12
Process exited with code 255.