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('Monday')->format('d-m-Y')); var_dump(getDay('Tuesday')->format('d-m-Y')); var_dump(getDay('Wednesday')->format('d-m-Y')); var_dump(getDay('Thursday')->format('d-m-Y')); var_dump(getDay('Friday')->format('d-m-Y')); var_dump(getDay('Saturday')->format('d-m-Y')); var_dump(getDay('Sunday')->format('d-m-Y'));
based on u1bt3
Output for 5.4.11 - 5.4.45, 7.0.20 - 7.2.0
string(10) "04-01-2016" string(10) "05-01-2016" string(10) "06-01-2016" string(10) "07-01-2016" string(10) "08-01-2016" string(10) "09-01-2016" string(10) "10-01-2016"
Output for 7.0.6
string(10) "16-05-2016" string(10) "17-05-2016" string(10) "18-05-2016" string(10) "19-05-2016" string(10) "20-05-2016" string(10) "21-05-2016" string(10) "22-05-2016"
Output for 5.5.30, 5.6.15 - 5.6.16, 7.0.5
string(10) "28-03-2016" string(10) "29-03-2016" string(10) "30-03-2016" string(10) "31-03-2016" string(10) "01-04-2016" string(10) "02-04-2016" string(10) "03-04-2016"
Output for 5.5.33, 5.6.19, 7.0.4
string(10) "07-03-2016" string(10) "08-03-2016" string(10) "09-03-2016" string(10) "10-03-2016" string(10) "11-03-2016" string(10) "12-03-2016" string(10) "13-03-2016"
Output for 5.5.32, 5.6.17 - 5.6.18, 7.0.3
string(10) "14-03-2016" string(10) "15-03-2016" string(10) "16-03-2016" string(10) "17-03-2016" string(10) "18-03-2016" string(10) "19-03-2016" string(10) "20-03-2016"
Output for 5.5.31, 7.0.0 - 7.0.2
string(10) "21-03-2016" string(10) "22-03-2016" string(10) "23-03-2016" string(10) "24-03-2016" string(10) "25-03-2016" string(10) "26-03-2016" string(10) "27-03-2016"
Output for 5.6.21
string(10) "02-05-2016" string(10) "03-05-2016" string(10) "04-05-2016" string(10) "05-05-2016" string(10) "06-05-2016" string(10) "07-05-2016" string(10) "08-05-2016"
Output for 5.6.20
string(10) "04-04-2016" string(10) "05-04-2016" string(10) "06-04-2016" string(10) "07-04-2016" string(10) "08-04-2016" string(10) "09-04-2016" string(10) "10-04-2016"
Output for 5.5.29, 5.5.34, 5.6.13 - 5.6.14
string(10) "11-04-2016" string(10) "12-04-2016" string(10) "13-04-2016" string(10) "14-04-2016" string(10) "15-04-2016" string(10) "16-04-2016" string(10) "17-04-2016"
Output for 5.5.27 - 5.5.28, 5.6.11 - 5.6.12
string(10) "18-04-2016" string(10) "19-04-2016" string(10) "20-04-2016" string(10) "21-04-2016" string(10) "22-04-2016" string(10) "23-04-2016" string(10) "24-04-2016"
Output for 5.5.25 - 5.5.26, 5.6.8 - 5.6.10
string(10) "25-04-2016" string(10) "26-04-2016" string(10) "27-04-2016" string(10) "28-04-2016" string(10) "29-04-2016" string(10) "30-04-2016" string(10) "01-05-2016"
Output for 5.5.24, 5.5.35
string(10) "23-05-2016" string(10) "24-05-2016" string(10) "25-05-2016" string(10) "26-05-2016" string(10) "27-05-2016" string(10) "28-05-2016" string(10) "29-05-2016"
Output for 5.3.21 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/gIBIB on line 4
Process exited with code 255.