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($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.2.6
object(DateTime)#1 (3) { ["date"]=> string(26) "2014-06-02 11:43:29.002930" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(12) "14 0606 0606"
Output for 7.2.0
object(DateTime)#1 (3) { ["date"]=> string(26) "2014-06-02 11:43:29.029353" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(12) "14 0606 0606"
Output for 7.1.20
object(DateTime)#1 (3) { ["date"]=> string(26) "2014-06-02 11:43:29.003876" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(12) "14 0606 0606"
Output for 7.1.10
object(DateTime)#1 (3) { ["date"]=> string(26) "2014-06-02 11:43:29.003096" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(12) "14 0606 0606"
Output for 7.1.7
object(DateTime)#1 (3) { ["date"]=> string(26) "2014-06-02 11:43:29.003200" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(12) "14 0606 0606"
Output for 7.1.6
object(DateTime)#1 (3) { ["date"]=> string(26) "2014-06-02 11:43:29.011595" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(12) "14 0606 0606"
Output for 7.1.5
object(DateTime)#1 (3) { ["date"]=> string(26) "2014-06-02 11:43:29.011971" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(12) "14 0606 0606"
Output for 7.1.0
object(DateTime)#1 (3) { ["date"]=> string(26) "2014-06-02 11:43:29.004018" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(12) "14 0606 0606"
Output for 5.4.42, 5.6.28, 7.0.14 - 7.0.20
object(DateTime)#1 (3) { ["date"]=> string(26) "2014-06-02 11:43:29.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(12) "14 0606 0606"
Output for 7.0.6
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-05-02 08:46:58.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(12) "16 0505 0606"
Output for 7.0.5
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-28 21:41:59.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(12) "16 0404 0101"
Output for 7.0.4
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-07 08:05:16.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(12) "16 0303 1111"
Output for 7.0.3
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-14 08:39:28.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(12) "16 0303 1818"
Output for 7.0.2
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-21 14:25:13.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(12) "16 0303 2525"
Output for 7.0.1
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-21 19:25:17.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(12) "16 0303 2525"
Output for 7.0.0
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-21 20:59:50.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(12) "16 0303 2525"
Output for 5.6.21
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-05-02 04:07:51.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(12) "16 0505 0606"
Output for 5.6.20
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-04 20:36:29.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(12) "16 0404 0808"
Output for 5.6.19
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-07 16:13:05.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(12) "16 0303 1111"
Output for 5.6.18
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-14 23:58:33.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(12) "16 0303 1818"
Output for 5.6.17
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-14 12:57:21.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(12) "16 0303 1818"
Output for 5.6.16
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-21 22:45:42.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(12) "16 0303 2525"
Output for 5.6.15
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-28 23:38:28.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(12) "16 0404 0101"
Output for 5.6.14
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-28 02:14:39.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(12) "16 0404 0101"
Output for 5.6.13
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-11 06:08:02.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(12) "16 0404 1515"
Output for 5.6.12
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-18 19:47:37.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(12) "16 0404 2222"
Output for 5.6.11
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-18 02:53:44.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(12) "16 0404 2222"
Output for 5.6.10
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-25 04:36:59.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(12) "16 0404 2929"
Output for 5.6.9
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-25 09:34:50.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(12) "16 0404 2929"
Output for 5.6.8
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-25 17:36:22.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(12) "16 0404 2929"
Output for 5.6.7
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-05-23 13:15:22.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(12) "16 0505 2727"
Output for 5.5.35
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-05-16 07:51:30.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(12) "16 0505 2020"
Output for 5.5.34
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-04 22:58:43.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(12) "16 0404 0808"
Output for 5.5.33
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-07 19:01:03.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(12) "16 0303 1111"
Output for 5.5.32
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-14 01:50:38.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(12) "16 0303 1818"
Output for 5.5.31
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-14 15:43:31.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(12) "16 0303 1818"
Output for 5.5.30
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-28 01:46:41.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(12) "16 0404 0101"
Output for 5.5.29
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-11 20:13:30.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(12) "16 0404 1515"
Output for 5.5.28
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-18 22:53:50.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(12) "16 0404 2222"
Output for 5.5.27
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-18 01:24:32.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(12) "16 0404 2222"
Output for 5.5.26
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-25 07:03:46.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(12) "16 0404 2929"
Output for 5.5.25
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-25 13:08:26.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(12) "16 0404 2929"
Output for 5.5.24
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-05-23 20:22:21.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(12) "16 0505 2727"
Output for 5.4.45
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-08-31 03:01:10.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(12) "15 0909 0404"
Output for 5.4.44
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-08-31 03:01:07.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(12) "15 0909 0404"
Output for 5.4.43
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-08-31 03:01:03.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(12) "15 0909 0404"
Output for 5.4.41
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-08-31 03:00:59.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(12) "15 0909 0404"
Output for 5.4.40
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-08-31 03:00:57.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(12) "15 0909 0404"
Output for 5.4.39
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-08-31 03:00:56.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(12) "15 0909 0404"
Output for 5.4.38
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-03-02 22:01:03.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(12) "15 0303 0606"
Output for 5.4.35 - 5.4.37
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-03-02 22:00:56.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(12) "15 0303 0606"
Output for 5.4.34
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-03-02 22:00:55.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(12) "15 0303 0606"
Output for 5.4.32
object(DateTime)#1 (3) { ["date"]=> string(26) "2014-09-08 15:18:29.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(12) "14 0909 1212"
Output for 5.4.31
object(DateTime)#1 (3) { ["date"]=> string(26) "2014-09-08 15:18:27.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(12) "14 0909 1212"
Output for 5.4.30
object(DateTime)#1 (3) { ["date"]=> string(26) "2014-09-08 15:18:22.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(12) "14 0909 1212"
Output for 5.4.19 - 5.4.29
object(DateTime)#1 (3) { ["date"]=> string(19) "2014-06-02 11:43:32" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(12) "14 0606 0606"
Output for 5.4.4 - 5.4.18
object(DateTime)#1 (3) { ["date"]=> string(19) "2014-06-02 11:43:33" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(12) "14 0606 0606"
Output for 5.4.0 - 5.4.3
object(DateTime)#1 (3) { ["date"]=> string(19) "2014-06-02 11:43:34" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(12) "14 0606 0606"
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/rQdVo 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/rQdVo on line 4
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/rQdVo on line 4
Process exited with code 255.