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('Y') ."-".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:22.004139" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(10) "2014-06-06"
Output for 5.6.28, 7.0.14
object(DateTime)#1 (3) { ["date"]=> string(26) "2014-06-02 11:46:22.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(10) "2014-06-06"
Output for 7.0.6
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-05-02 08:47:07.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(10) "2016-05-06"
Output for 7.0.5
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-28 21:42:07.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(10) "2016-04-01"
Output for 7.0.4
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-07 08:05:30.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(10) "2016-03-11"
Output for 7.0.3
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-14 08:39:42.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(10) "2016-03-18"
Output for 7.0.2
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-21 14:25:27.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(10) "2016-03-25"
Output for 7.0.1
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-21 19:25:31.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(10) "2016-03-25"
Output for 7.0.0
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-21 21:00:03.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(10) "2016-03-25"
Output for hhvm-3.12.0
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-28 01:12:56.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(10) "2016-04-01"
Output for hhvm-3.10.0

Process exited with code 153.
Output for 5.6.21
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-05-02 04:08:01.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(10) "2016-05-06"
Output for 5.6.20
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-04 20:36:39.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(10) "2016-04-08"
Output for 5.6.19
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-07 16:13:17.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(10) "2016-03-11"
Output for 5.6.18
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-14 23:58:47.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(10) "2016-03-18"
Output for 5.6.17
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-14 12:57:35.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(10) "2016-03-18"
Output for 5.6.16
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-21 22:45:55.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(10) "2016-03-25"
Output for 5.6.15
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-28 23:38:42.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(10) "2016-04-01"
Output for 5.6.14
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-28 02:14:49.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(10) "2016-04-01"
Output for 5.6.13
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-11 06:08:11.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(10) "2016-04-15"
Output for 5.6.12
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-18 19:47:48.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(10) "2016-04-22"
Output for 5.6.11
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-18 02:53:55.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(10) "2016-04-22"
Output for 5.6.10
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-25 04:37:08.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(10) "2016-04-29"
Output for 5.6.9
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-25 09:35:01.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(10) "2016-04-29"
Output for 5.6.8
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-25 17:36:32.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(10) "2016-04-29"
Output for 5.6.7
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-05-23 13:15:33.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(10) "2016-05-27"
Output for 5.5.35
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-05-16 07:51:42.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(10) "2016-05-20"
Output for 5.5.34
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-04 22:58:53.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(10) "2016-04-08"
Output for 5.5.33
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-07 19:10:43.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(10) "2016-03-11"
Output for 5.5.32
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-14 01:50:52.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(10) "2016-03-18"
Output for 5.5.31
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-14 15:43:45.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(10) "2016-03-18"
Output for 5.5.30
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-28 01:46:51.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(10) "2016-04-01"
Output for 5.5.29
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-11 20:13:40.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(10) "2016-04-15"
Output for 5.5.28
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-18 22:54:01.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(10) "2016-04-22"
Output for 5.5.27
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-18 01:24:42.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(10) "2016-04-22"
Output for 5.5.26
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-25 07:03:57.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(10) "2016-04-29"
Output for 5.5.25
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-25 13:08:37.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(10) "2016-04-29"
Output for 5.5.24
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-05-23 20:22:25.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(10) "2016-05-27"
Output for 5.4.45
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-08-31 03:01:21.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(10) "2015-09-04"
Output for 5.4.44
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-08-31 03:01:18.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(10) "2015-09-04"
Output for 5.4.43
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-08-31 03:01:15.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(10) "2015-09-04"
Output for 5.4.42
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-08-31 03:01:13.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(10) "2015-09-04"
Output for 5.4.41
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-08-31 03:01:11.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(10) "2015-09-04"
Output for 5.4.39 - 5.4.40
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-08-31 03:01:08.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(10) "2015-09-04"
Output for 5.4.38
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-03-02 21:58:57.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(10) "2015-03-06"
Output for 5.4.35 - 5.4.37
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-03-02 21:58:50.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(10) "2015-03-06"
Output for 5.4.34
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-03-02 21:58:49.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(10) "2015-03-06"
Output for 5.4.32
object(DateTime)#1 (3) { ["date"]=> string(26) "2014-09-08 15:15:38.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(10) "2014-09-12"
Output for 5.4.31
object(DateTime)#1 (3) { ["date"]=> string(26) "2014-09-08 15:15:37.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(10) "2014-09-12"
Output for 5.4.30
object(DateTime)#1 (3) { ["date"]=> string(26) "2014-09-08 15:15:32.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(10) "2014-09-12"
Output for 5.4.27 - 5.4.29
object(DateTime)#1 (3) { ["date"]=> string(19) "2014-06-02 11:46:24" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(10) "2014-06-06"
Output for 5.4.11 - 5.4.26
object(DateTime)#1 (3) { ["date"]=> string(19) "2014-06-02 11:46:25" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(10) "2014-06-06"
Output for 5.4.0 - 5.4.10
object(DateTime)#1 (3) { ["date"]=> string(19) "2014-06-02 11:46:26" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(10) "2014-06-06"
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/Vtqlj 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/Vtqlj on line 4
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/Vtqlj on line 4
Process exited with code 255.