3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function getDay($day) { $days = ['Monday' => 1, 'Tuesday' => 2, 'Wednesday' => 3, 'Thursday' => 4, 'Friday' => 5, 'Saturday' => 6, 'Sunday' => 7]; $today = new \DateTime(); $today->setISODate((int)$today->format('o'), (int)$today->format('W'), $days[ucfirst($day)]); return $today; } var_dump(getDay('Saturday')->format('d f Y')); var_dump(getDay('Sunday')->format('d f Y'));
based on 5B2uV
Output for 5.4.8 - 5.4.45, 5.6.28, 7.0.20 - 7.3.0alpha1
string(9) "26 f 2015" string(9) "27 f 2015"
Output for 5.6.21, 7.0.6
string(9) "07 f 2016" string(9) "08 f 2016"
Output for 5.5.30, 5.6.14 - 5.6.16, 7.0.5
string(9) "02 f 2016" string(9) "03 f 2016"
Output for 5.5.33, 5.6.19, 7.0.4
string(9) "12 f 2016" string(9) "13 f 2016"
Output for 5.5.31 - 5.5.32, 5.6.17 - 5.6.18, 7.0.3
string(9) "19 f 2016" string(9) "20 f 2016"
Output for 7.0.0 - 7.0.2
string(9) "26 f 2016" string(9) "27 f 2016"
Output for 5.6.20
string(9) "09 f 2016" string(9) "10 f 2016"
Output for 5.5.29, 5.5.34, 5.6.13
string(9) "16 f 2016" string(9) "17 f 2016"
Output for 5.5.27 - 5.5.28, 5.6.11 - 5.6.12
string(9) "23 f 2016" string(9) "24 f 2016"
Output for 5.5.25 - 5.5.26, 5.6.8 - 5.6.10
string(9) "30 f 2016" string(9) "01 f 2016"
Output for 5.5.35
string(9) "21 f 2016" string(9) "22 f 2016"
Output for 5.5.24
string(9) "28 f 2016" string(9) "29 f 2016"
Output for 5.4.1 - 5.4.7
string(9) "31 f 2015" string(9) "01 f 2015"
Output for 5.3.18 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/6Pr4l on line 4
Process exited with code 255.