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('dS F Y'));
based on rEvPe
Output for 5.4.8 - 5.4.45, 5.6.28, 7.0.20 - 7.2.0
string(17) "26 September 2015" string(19) "27th September 2015"
Output for 5.6.21, 7.0.6
string(11) "07 May 2016" string(13) "08th May 2016"
Output for 5.5.30, 5.6.14 - 5.6.16, 7.0.5
string(13) "02 April 2016" string(15) "03rd April 2016"
Output for 5.5.33, 5.6.19, 7.0.4
string(13) "12 March 2016" string(15) "13th March 2016"
Output for 5.5.32, 5.6.17 - 5.6.18, 7.0.3
string(13) "19 March 2016" string(15) "20th March 2016"
Output for 5.5.31, 7.0.0 - 7.0.2
string(13) "26 March 2016" string(15) "27th March 2016"
Output for 5.6.20
string(13) "09 April 2016" string(15) "10th April 2016"
Output for 5.5.29, 5.5.34, 5.6.13
string(13) "16 April 2016" string(15) "17th April 2016"
Output for 5.5.27 - 5.5.28, 5.6.11 - 5.6.12
string(13) "23 April 2016" string(15) "24th April 2016"
Output for 5.5.25 - 5.5.26, 5.6.8 - 5.6.10
string(13) "30 April 2016" string(13) "01st May 2016"
Output for 5.5.35
string(11) "21 May 2016" string(13) "22nd May 2016"
Output for 5.5.24
string(11) "28 May 2016" string(13) "29th May 2016"
Output for 5.4.1 - 5.4.7
string(15) "31 October 2015" string(18) "01st November 2015"
Output for 5.3.18 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/5B2uV on line 4
Process exited with code 255.