3v4l.org

run code in 150+ 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($today->format('o'), $today->format('W'), $days[ucfirst($day)]); return $today; } $day_start = (getDay('Monday')->format("Y-m-d")); $day_end = (getDay('Friday')->format("Y-m-d")); echo $day_start.'<br />'; echo $day_end;
based on fg0QZ
Output for 5.4.0 - 5.4.32, 5.6.28, 7.0.14 - 7.1.0
2014-09-01<br />2014-09-05
Output for 5.6.21, 7.0.6
2016-05-02<br />2016-05-06
Output for 5.5.30, 5.6.14 - 5.6.15, 7.0.5
2016-03-28<br />2016-04-01
Output for 5.5.33, 5.6.19, 7.0.4
2016-03-07<br />2016-03-11
Output for 5.5.31 - 5.5.32, 5.6.17 - 5.6.18, 7.0.3
2016-03-14<br />2016-03-18
Output for 5.6.16, 7.0.0 - 7.0.2
2016-03-21<br />2016-03-25
Output for 5.5.34, 5.6.20
2016-04-04<br />2016-04-08
Output for 5.5.29, 5.6.13
2016-04-11<br />2016-04-15
Output for 5.5.27 - 5.5.28, 5.6.11 - 5.6.12
2016-04-18<br />2016-04-22
Output for 5.5.25 - 5.5.26, 5.6.8 - 5.6.10
2016-04-25<br />2016-04-29
Output for 5.5.24, 5.6.7
2016-05-23<br />2016-05-27
Output for 5.5.35
2016-05-16<br />2016-05-20
Output for 5.4.45
2015-09-07<br />2015-09-11
Output for 5.4.39 - 5.4.44
2015-08-03<br />2015-08-07
Output for 5.4.38
2015-02-16<br />2015-02-20
Output for 5.4.36 - 5.4.37
2015-02-02<br />2015-02-06
Output for 5.4.34 - 5.4.35
2014-11-10<br />2014-11-14
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/i65k5 on line 4
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected '[' in /in/i65k5 on line 4
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/i65k5 on line 4
Process exited with code 255.