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')); $fulldate = getDay('Friday')->format('yyyy') ."-".getDay('Friday')->format('m') ."-". getDay('Friday')->format('d'); var_dump($fulldate);
Output for 7.1.0
object(DateTime)#1 (3) { ["date"]=> string(26) "2014-06-02 11:46:02.004069" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(14) "14141414-06-06"
Output for 5.6.28, 7.0.14
object(DateTime)#1 (3) { ["date"]=> string(26) "2014-06-02 11:46:02.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(14) "14141414-06-06"
Output for 7.0.6
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-05-02 08:48:12.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(14) "16161616-05-06"
Output for 7.0.5
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-28 21:43:12.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(14) "16161616-04-01"
Output for 7.0.4
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-07 08:06:48.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(14) "16161616-03-11"
Output for 7.0.3
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-14 08:41:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(14) "16161616-03-18"
Output for 7.0.2
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-21 14:26:45.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(14) "16161616-03-25"
Output for 7.0.1
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-21 19:26:44.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(14) "16161616-03-25"
Output for 7.0.0
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-21 21:01:09.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(14) "16161616-03-25"
Output for 5.6.21
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-05-02 04:09:10.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(14) "16161616-05-06"
Output for 5.6.20
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-04 20:37:44.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(14) "16161616-04-08"
Output for 5.6.19
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-07 16:14:30.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(14) "16161616-03-11"
Output for 5.6.18
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-14 00:00:05.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(14) "16161616-03-18"
Output for 5.6.17
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-14 12:58:53.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(14) "16161616-03-18"
Output for 5.6.16
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-21 22:47:01.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(14) "16161616-03-25"
Output for 5.6.15
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-28 23:39:47.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(14) "16161616-04-01"
Output for 5.6.14
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-28 02:15:53.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(14) "16161616-04-01"
Output for 5.6.13
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-11 06:09:21.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(14) "16161616-04-15"
Output for 5.6.12
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-18 19:49:03.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(14) "16161616-04-22"
Output for 5.6.11
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-18 02:54:59.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(14) "16161616-04-22"
Output for 5.6.10
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-25 04:38:25.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(14) "16161616-04-29"
Output for 5.6.9
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-25 09:36:05.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(14) "16161616-04-29"
Output for 5.6.8
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-25 17:37:53.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(14) "16161616-04-29"
Output for 5.6.7
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-05-23 13:18:35.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(14) "16161616-05-27"
Output for 5.5.35
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-05-16 07:52:41.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(14) "16161616-05-20"
Output for 5.5.34
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-04 22:59:58.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(14) "16161616-04-08"
Output for 5.5.33
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-07 19:12:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(14) "16161616-03-11"
Output for 5.5.32
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-14 01:52:09.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(14) "16161616-03-18"
Output for 5.5.31
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-14 15:44:59.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(14) "16161616-03-18"
Output for 5.5.30
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-28 01:47:57.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(14) "16161616-04-01"
Output for 5.5.29
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-11 20:14:49.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(14) "16161616-04-15"
Output for 5.5.28
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-18 22:55:07.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(14) "16161616-04-22"
Output for 5.5.27
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-18 01:25:48.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(14) "16161616-04-22"
Output for 5.5.26
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-25 07:05:07.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(14) "16161616-04-29"
Output for 5.5.25
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-25 13:09:57.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(14) "16161616-04-29"
Output for 5.5.24
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-05-23 20:23:26.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(14) "16161616-05-27"
Output for 5.4.45
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-08-31 03:04:20.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(14) "15151515-09-04"
Output for 5.4.44
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-08-31 03:04:16.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(14) "15151515-09-04"
Output for 5.4.43
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-08-31 03:04:13.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(14) "15151515-09-04"
Output for 5.4.42
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-08-31 03:04:12.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(14) "15151515-09-04"
Output for 5.4.41
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-08-31 03:04:10.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(14) "15151515-09-04"
Output for 5.4.39 - 5.4.40
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-08-31 03:04:07.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(14) "15151515-09-04"
Output for 5.4.38
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-03-02 22:02:57.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(14) "15151515-03-06"
Output for 5.4.36 - 5.4.37
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-03-02 22:02:50.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(14) "15151515-03-06"
Output for 5.4.34 - 5.4.35
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-03-02 22:02:49.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(14) "15151515-03-06"
Output for 5.4.32
object(DateTime)#1 (3) { ["date"]=> string(26) "2014-09-08 15:21:35.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(14) "14141414-09-12"
Output for 5.4.31
object(DateTime)#1 (3) { ["date"]=> string(26) "2014-09-08 15:21:33.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(14) "14141414-09-12"
Output for 5.4.30
object(DateTime)#1 (3) { ["date"]=> string(26) "2014-09-08 15:21:26.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(14) "14141414-09-12"
Output for 5.4.19 - 5.4.29
object(DateTime)#1 (3) { ["date"]=> string(19) "2014-06-02 11:46:05" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(14) "14141414-06-06"
Output for 5.4.0 - 5.4.18
object(DateTime)#1 (3) { ["date"]=> string(19) "2014-06-02 11:46:06" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(14) "14141414-06-06"
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/BX09S 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/BX09S on line 4
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/BX09S on line 4
Process exited with code 255.