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('y "-" mm "-" dd'));
Output for 7.1.0
object(DateTime)#1 (3) { ["date"]=> string(26) "2014-06-02 11:42:48.004138" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(20) "14 "-" 0606 "-" 0606"
Output for 5.6.28, 7.0.14
object(DateTime)#1 (3) { ["date"]=> string(26) "2014-06-02 11:42:48.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(20) "14 "-" 0606 "-" 0606"
Output for 7.0.6
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-05-02 08:47:08.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(20) "16 "-" 0505 "-" 0606"
Output for 7.0.5
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-28 21:42:09.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(20) "16 "-" 0404 "-" 0101"
Output for 7.0.4
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-07 08:05:40.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(20) "16 "-" 0303 "-" 1111"
Output for 7.0.3
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-14 08:39:54.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(20) "16 "-" 0303 "-" 1818"
Output for 7.0.2
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-21 14:25:38.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(20) "16 "-" 0303 "-" 2525"
Output for 7.0.1
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-21 19:25:40.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(20) "16 "-" 0303 "-" 2525"
Output for 7.0.0
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-21 21:00:21.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(20) "16 "-" 0303 "-" 2525"
Output for 5.6.21
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-05-02 04:08:03.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(20) "16 "-" 0505 "-" 0606"
Output for 5.6.20
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-04 20:36:41.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(20) "16 "-" 0404 "-" 0808"
Output for 5.6.19
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-07 16:13:27.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(20) "16 "-" 0303 "-" 1111"
Output for 5.6.18
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-14 23:58:58.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(20) "16 "-" 0303 "-" 1818"
Output for 5.6.17
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-14 12:57:46.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(20) "16 "-" 0303 "-" 1818"
Output for 5.6.16
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-21 22:46:10.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(20) "16 "-" 0303 "-" 2525"
Output for 5.6.15
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-28 23:38:58.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(20) "16 "-" 0404 "-" 0101"
Output for 5.6.14
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-28 02:14:51.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(20) "16 "-" 0404 "-" 0101"
Output for 5.6.13
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-11 06:08:13.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(20) "16 "-" 0404 "-" 1515"
Output for 5.6.12
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-18 19:47:50.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(20) "16 "-" 0404 "-" 2222"
Output for 5.6.11
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-18 02:53:57.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(20) "16 "-" 0404 "-" 2222"
Output for 5.6.10
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-25 04:37:10.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(20) "16 "-" 0404 "-" 2929"
Output for 5.6.9
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-25 09:35:03.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(20) "16 "-" 0404 "-" 2929"
Output for 5.6.8
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-25 17:36:34.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(20) "16 "-" 0404 "-" 2929"
Output for 5.6.7
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-05-23 13:15:38.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(20) "16 "-" 0505 "-" 2727"
Output for 5.5.35
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-05-16 07:51:34.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(20) "16 "-" 0505 "-" 2020"
Output for 5.5.34
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-04 22:58:55.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(20) "16 "-" 0404 "-" 0808"
Output for 5.5.33
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-07 19:10:53.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(20) "16 "-" 0303 "-" 1111"
Output for 5.5.32
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-14 01:51:03.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(20) "16 "-" 0303 "-" 1818"
Output for 5.5.31
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-14 15:43:55.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(20) "16 "-" 0303 "-" 1818"
Output for 5.5.30
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-28 01:46:53.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(20) "16 "-" 0404 "-" 0101"
Output for 5.5.29
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-11 20:13:41.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(20) "16 "-" 0404 "-" 1515"
Output for 5.5.28
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-18 22:54:03.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(20) "16 "-" 0404 "-" 2222"
Output for 5.5.27
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-18 01:24:44.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(20) "16 "-" 0404 "-" 2222"
Output for 5.5.26
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-25 07:04:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(20) "16 "-" 0404 "-" 2929"
Output for 5.5.25
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-25 13:08:39.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(20) "16 "-" 0404 "-" 2929"
Output for 5.5.24
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-05-23 20:22:26.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(20) "16 "-" 0505 "-" 2727"
Output for 5.4.45
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-08-31 03:02:15.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(20) "15 "-" 0909 "-" 0404"
Output for 5.4.44
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-08-31 03:02:11.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(20) "15 "-" 0909 "-" 0404"
Output for 5.4.43
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-08-31 03:02:08.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(20) "15 "-" 0909 "-" 0404"
Output for 5.4.42
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-08-31 03:02:07.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(20) "15 "-" 0909 "-" 0404"
Output for 5.4.41
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-08-31 03:02:05.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(20) "15 "-" 0909 "-" 0404"
Output for 5.4.39 - 5.4.40
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-08-31 03:02:02.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(20) "15 "-" 0909 "-" 0404"
Output for 5.4.38
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-03-02 22:00:26.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(20) "15 "-" 0303 "-" 0606"
Output for 5.4.35 - 5.4.37
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-03-02 22:00:18.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(20) "15 "-" 0303 "-" 0606"
Output for 5.4.34
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-03-02 22:00:17.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(20) "15 "-" 0303 "-" 0606"
Output for 5.4.32
object(DateTime)#1 (3) { ["date"]=> string(26) "2014-09-08 15:17:23.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(20) "14 "-" 0909 "-" 1212"
Output for 5.4.31
object(DateTime)#1 (3) { ["date"]=> string(26) "2014-09-08 15:17:21.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(20) "14 "-" 0909 "-" 1212"
Output for 5.4.30
object(DateTime)#1 (3) { ["date"]=> string(26) "2014-09-08 15:17:15.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(20) "14 "-" 0909 "-" 1212"
Output for 5.4.21 - 5.4.29
object(DateTime)#1 (3) { ["date"]=> string(19) "2014-06-02 11:42:51" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(20) "14 "-" 0606 "-" 0606"
Output for 5.4.7 - 5.4.20
object(DateTime)#1 (3) { ["date"]=> string(19) "2014-06-02 11:42:52" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(20) "14 "-" 0606 "-" 0606"
Output for 5.4.0 - 5.4.6
object(DateTime)#1 (3) { ["date"]=> string(19) "2014-06-02 11:42:53" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(20) "14 "-" 0606 "-" 0606"
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/gf2vC 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/gf2vC on line 4
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/gf2vC on line 4
Process exited with code 255.