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((int)$today->format('o'), (int)$today->format('W'), $days[ucfirst($day)]); return $today; } var_dump(getDay('Monday')->getTimestamp()); var_dump(getDay('Friday'));
based on 6F6Oo
Output for 7.2.0
int(1453761330) object(DateTime)#1 (3) { ["date"]=> string(26) "2016-01-29 23:35:30.004458" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.10
int(1453761330) object(DateTime)#1 (3) { ["date"]=> string(26) "2016-01-29 23:35:30.003410" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.7
int(1453761330) object(DateTime)#1 (3) { ["date"]=> string(26) "2016-01-29 23:35:30.002563" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.6
int(1453761330) object(DateTime)#1 (3) { ["date"]=> string(26) "2016-01-29 23:35:30.013197" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.5
int(1453761330) object(DateTime)#1 (3) { ["date"]=> string(26) "2016-01-29 23:35:30.011416" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.0
int(1453761330) object(DateTime)#1 (3) { ["date"]=> string(26) "2016-01-29 23:35:30.004191" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.6.28, 7.0.20
int(1453761330) object(DateTime)#1 (3) { ["date"]=> string(26) "2016-01-29 23:35:30.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.0.6
int(1463401256) object(DateTime)#1 (3) { ["date"]=> string(26) "2016-05-20 14:20:56.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.0.5
int(1459152797) object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-01 10:13:17.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.0.4
int(1457385725) object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-11 22:22:05.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.0.3
int(1457996272) object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-18 23:57:52.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.0.2
int(1458536695) object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-25 06:04:55.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.0.1
int(1458547617) object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-25 09:06:57.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.0.0
int(1458554286) object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-25 10:58:06.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.6.21
int(1462201699) object(DateTime)#1 (3) { ["date"]=> string(26) "2016-05-06 17:08:19.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.6.20
int(1459754118) object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-08 09:15:18.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.6.19
int(1457328684) object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-11 06:31:24.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.6.18
int(1457965907) object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-18 15:31:47.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.6.17
int(1457921390) object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-18 03:09:50.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.6.16
int(1459158475) object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-01 11:47:55.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.6.15
int(1459161462) object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-01 12:37:42.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.6.14
int(1460391641) object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-15 18:20:41.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.6.13
int(1460393984) object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-15 18:59:44.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.6.12
int(1460964653) object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-22 09:30:53.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.6.11
int(1460987812) object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-22 15:56:52.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.6.10
int(1461600133) object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-29 18:02:13.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.6.9
int(1461619871) object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-29 23:31:11.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.6.8
int(1461563827) object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-29 07:57:07.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.5.35
int(1463966589) object(DateTime)#1 (3) { ["date"]=> string(26) "2016-05-27 03:23:09.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.5.34
int(1460366985) object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-15 11:29:45.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.5.33
int(1457339803) object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-11 09:36:43.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.5.32
int(1457980325) object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-18 19:32:05.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.5.31
int(1458537580) object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-25 06:19:40.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.5.30
int(1459168117) object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-01 14:28:37.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.5.29
int(1460359020) object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-15 09:17:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.5.28
int(1460976662) object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-22 12:51:02.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.5.27
int(1460982428) object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-22 14:27:08.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.5.26
int(1461609862) object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-29 20:44:22.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.5.25
int(1461550328) object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-29 04:12:08.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.5.24
int(1463992959) object(DateTime)#1 (3) { ["date"]=> string(26) "2016-05-27 10:42:39.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.4.45
int(1453761334) object(DateTime)#1 (3) { ["date"]=> string(26) "2016-01-29 23:35:34.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.4.44
int(1453761335) object(DateTime)#1 (3) { ["date"]=> string(26) "2016-01-29 23:35:35.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.4.42 - 5.4.43
int(1453761336) object(DateTime)#1 (3) { ["date"]=> string(26) "2016-01-29 23:35:36.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.4.41
int(1453761337) object(DateTime)#1 (3) { ["date"]=> string(26) "2016-01-29 23:35:37.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.4.40
int(1453761338) object(DateTime)#1 (3) { ["date"]=> string(26) "2016-01-29 23:35:38.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.4.38 - 5.4.39
int(1453761339) object(DateTime)#1 (3) { ["date"]=> string(26) "2016-01-29 23:35:39.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.4.36 - 5.4.37
int(1453761340) object(DateTime)#1 (3) { ["date"]=> string(26) "2016-01-29 23:35:40.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.4.34 - 5.4.35
int(1453761341) object(DateTime)#1 (3) { ["date"]=> string(26) "2016-01-29 23:35:41.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.4.31 - 5.4.32
int(1453761342) object(DateTime)#1 (3) { ["date"]=> string(26) "2016-01-29 23:35:42.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.4.30
int(1453761343) object(DateTime)#1 (3) { ["date"]=> string(26) "2016-01-29 23:35:43.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.4.27 - 5.4.29
int(1453761343) object(DateTime)#1 (3) { ["date"]=> string(19) "2016-01-29 23:35:43" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.4.24 - 5.4.26
int(1453761344) object(DateTime)#1 (3) { ["date"]=> string(19) "2016-01-29 23:35:44" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.4.21 - 5.4.23
int(1453761345) object(DateTime)#1 (3) { ["date"]=> string(19) "2016-01-29 23:35:45" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.4.19 - 5.4.20
int(1453761346) object(DateTime)#1 (3) { ["date"]=> string(19) "2016-01-29 23:35:46" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.4.17 - 5.4.18
int(1453761347) object(DateTime)#1 (3) { ["date"]=> string(19) "2016-01-29 23:35:47" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.4.13 - 5.4.16
int(1453761348) object(DateTime)#1 (3) { ["date"]=> string(19) "2016-01-29 23:35:48" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.4.12
int(1453761349) object(DateTime)#1 (3) { ["date"]=> string(19) "2016-01-29 23:35:49" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.3.22 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/ogJUh on line 4
Process exited with code 255.