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(isFirstSundayOfMonth($day));
based on GD436
Output for 5.3.21 - 5.4.45, 5.6.28, 7.0.5, 7.0.20 - 7.2.0
bool(true)
Output for 5.5.24 - 5.6.21, 7.0.0 - 7.0.4, 7.0.6
bool(false)