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; } var_dump(getDay('Monday')); var_dump(getDay('Friday')->format('l dS F Y'));
Output for 7.1.0
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-03-23 19:15:13.006354" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(22) "Friday 27th March 2015"
Output for 5.6.28, 7.0.14
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-03-23 19:15:13.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(22) "Friday 27th March 2015"
Output for 7.0.6
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-05-02 08:02:44.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(20) "Friday 06th May 2016"
Output for 7.0.5
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-28 20:59:52.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(22) "Friday 01st April 2016"
Output for 7.0.4
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-07 07:15:49.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(22) "Friday 11th March 2016"
Output for 7.0.3
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-14 07:47:55.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(22) "Friday 18th March 2016"
Output for 7.0.2
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-21 13:33:09.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(22) "Friday 25th March 2016"
Output for 7.0.1
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-21 18:35:01.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(22) "Friday 25th March 2016"
Output for 7.0.0
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-21 20:15:34.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(22) "Friday 25th March 2016"
Output for 5.6.21
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-05-02 03:21:58.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(20) "Friday 06th May 2016"
Output for 5.6.20
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-04 19:49:44.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(22) "Friday 08th April 2016"
Output for 5.6.19
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-07 15:21:43.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(22) "Friday 11th March 2016"
Output for 5.6.18
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-14 23:07:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(22) "Friday 18th March 2016"
Output for 5.6.17
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-14 12:06:19.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(22) "Friday 18th March 2016"
Output for 5.6.16
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-21 22:00:51.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(22) "Friday 25th March 2016"
Output for 5.6.15
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-28 22:54:03.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(22) "Friday 01st April 2016"
Output for 5.6.14
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-28 01:28:33.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(22) "Friday 01st April 2016"
Output for 5.6.13
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-11 05:24:02.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(22) "Friday 15th April 2016"
Output for 5.6.12
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-18 19:00:07.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(22) "Friday 22nd April 2016"
Output for 5.6.11
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-18 01:59:22.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(22) "Friday 22nd April 2016"
Output for 5.6.10
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-25 03:50:37.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(22) "Friday 29th April 2016"
Output for 5.6.9
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-25 08:47:59.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(22) "Friday 29th April 2016"
Output for 5.6.8
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-25 16:48:04.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(22) "Friday 29th April 2016"
Output for 5.6.7
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-05-23 10:54:40.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(20) "Friday 27th May 2016"
Output for 5.5.35
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-05-16 07:03:26.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(20) "Friday 20th May 2016"
Output for 5.5.34
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-04 22:16:17.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(22) "Friday 08th April 2016"
Output for 5.5.33
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-07 18:11:37.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(22) "Friday 11th March 2016"
Output for 5.5.32
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-14 00:58:47.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(22) "Friday 18th March 2016"
Output for 5.5.31
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-14 14:53:33.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(22) "Friday 18th March 2016"
Output for 5.5.30
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-28 01:02:27.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(22) "Friday 01st April 2016"
Output for 5.5.29
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-11 19:29:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(22) "Friday 15th April 2016"
Output for 5.5.28
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-18 22:06:09.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(22) "Friday 22nd April 2016"
Output for 5.5.27
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-18 00:36:40.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(22) "Friday 22nd April 2016"
Output for 5.5.26
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-25 06:16:29.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(22) "Friday 29th April 2016"
Output for 5.5.25
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-25 12:19:29.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(22) "Friday 29th April 2016"
Output for 5.5.24
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-05-23 19:15:05.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(20) "Friday 27th May 2016"
Output for 5.4.40 - 5.4.45
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-10-12 17:10:42.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(24) "Friday 16th October 2015"
Output for 5.4.30 - 5.4.39
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-10-12 17:10:43.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(24) "Friday 16th October 2015"
Output for 5.4.19 - 5.4.29
object(DateTime)#1 (3) { ["date"]=> string(19) "2015-10-12 17:10:44" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(24) "Friday 16th October 2015"
Output for 5.4.9 - 5.4.18
object(DateTime)#1 (3) { ["date"]=> string(19) "2015-10-12 17:10:45" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(24) "Friday 16th October 2015"
Output for 5.4.0 - 5.4.8
object(DateTime)#1 (3) { ["date"]=> string(19) "2015-10-12 17:10:46" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(24) "Friday 16th October 2015"
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/5TBQb 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/5TBQb on line 4
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/5TBQb on line 4
Process exited with code 255.