3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php /** * Check if a given date is the first Monday of the month * * @param \DateTime $date * @return bool */ function isFirstSundayOfMonth(DateTime $date) { return (int)$date->format('d') <= 7 && $date->format('l') === 'Sunday'; } $day = new DateTime(); var_dump($day); var_dump(isFirstSundayOfMonth($day));
based on ROtWp
Output for 7.2.0
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-01-03 23:09:46.005024" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } bool(true)
Output for 7.1.10
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-01-03 23:09:46.003774" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } bool(true)
Output for 7.1.7
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-01-03 23:09:46.003768" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } bool(true)
Output for 7.1.6
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-01-03 23:09:46.012991" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } bool(true)
Output for 7.1.5
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-01-03 23:09:46.010315" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } bool(true)
Output for 7.1.0
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-01-03 23:09:46.004010" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } bool(true)
Output for 5.6.28, 7.0.20
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-01-03 23:09:46.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } bool(true)
Output for 7.0.6
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-05-21 13:16:58.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } bool(false)
Output for 7.0.5
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-03 09:19:40.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } bool(true)
Output for 7.0.4
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-10 21:26:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } bool(false)
Output for 7.0.3
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-18 22:49:13.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } bool(false)
Output for 7.0.2
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-23 05:02:20.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } bool(false)
Output for 7.0.1
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-24 08:10:20.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } bool(false)
Output for 7.0.0
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-27 10:03:41.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } bool(false)
Output for 5.6.21
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-05-02 16:12:24.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } bool(false)
Output for 5.6.20
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-10 08:21:27.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } bool(false)
Output for 5.6.19
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-08 05:33:57.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } bool(false)
Output for 5.6.18
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-15 14:30:48.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } bool(false)
Output for 5.6.17
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-20 02:02:41.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } bool(false)
Output for 5.6.16
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-28 10:52:57.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } bool(false)
Output for 5.6.15
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-29 11:42:07.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } bool(false)
Output for 5.6.14
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-14 17:24:38.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } bool(false)
Output for 5.6.13
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-15 18:03:34.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } bool(false)
Output for 5.6.12
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-20 08:32:38.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } bool(false)
Output for 5.6.11
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-24 14:58:27.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } bool(false)
Output for 5.6.10
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-25 17:04:28.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } bool(false)
Output for 5.6.9
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-27 22:30:21.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } bool(false)
Output for 5.6.8
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-30 07:00:47.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } bool(false)
Output for 5.5.35
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-05-23 01:57:14.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } bool(false)
Output for 5.5.34
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-11 10:35:15.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } bool(false)
Output for 5.5.33
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-09 08:32:49.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } bool(false)
Output for 5.5.32
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-17 18:26:50.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } bool(false)
Output for 5.5.31
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-21 05:11:29.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } bool(false)
Output for 5.5.30
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-01 13:34:19.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } bool(false)
Output for 5.5.29
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-17 08:21:17.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } bool(false)
Output for 5.5.28
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-21 11:51:04.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } bool(false)
Output for 5.5.27
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-22 13:30:03.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } bool(false)
Output for 5.5.26
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-26 19:45:01.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } bool(false)
Output for 5.5.25
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-29 03:09:58.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } bool(false)
Output for 5.5.24
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-05-24 09:34:06.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } bool(false)
Output for 5.4.45
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-01-03 23:09:50.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } bool(true)
Output for 5.4.44
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-01-03 23:09:51.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } bool(true)
Output for 5.4.43
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-01-03 23:09:52.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } bool(true)
Output for 5.4.41 - 5.4.42
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-01-03 23:09:53.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } bool(true)
Output for 5.4.39 - 5.4.40
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-01-03 23:09:54.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } bool(true)
Output for 5.4.37 - 5.4.38
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-01-03 23:09:55.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } bool(true)
Output for 5.4.35 - 5.4.36
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-01-03 23:09:56.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } bool(true)
Output for 5.4.32 - 5.4.34
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-01-03 23:09:57.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } bool(true)
Output for 5.4.30 - 5.4.31
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-01-03 23:09:58.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } bool(true)
Output for 5.3.29, 5.4.29
object(DateTime)#1 (3) { ["date"]=> string(19) "2016-01-03 23:09:58" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } bool(true)
Output for 5.4.25 - 5.4.28
object(DateTime)#1 (3) { ["date"]=> string(19) "2016-01-03 23:09:59" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } bool(true)
Output for 5.3.28, 5.4.22 - 5.4.24
object(DateTime)#1 (3) { ["date"]=> string(19) "2016-01-03 23:10:00" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } bool(true)
Output for 5.4.19 - 5.4.21
object(DateTime)#1 (3) { ["date"]=> string(19) "2016-01-03 23:10:01" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } bool(true)
Output for 5.3.27, 5.4.17 - 5.4.18
object(DateTime)#1 (3) { ["date"]=> string(19) "2016-01-03 23:10:02" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } bool(true)
Output for 5.3.24 - 5.3.26, 5.4.13 - 5.4.16
object(DateTime)#1 (3) { ["date"]=> string(19) "2016-01-03 23:10:03" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } bool(true)
Output for 5.3.21 - 5.3.23, 5.4.11 - 5.4.12
object(DateTime)#1 (3) { ["date"]=> string(19) "2016-01-03 23:10:04" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } bool(true)