3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Check if a given date is the first Monday of the month * * @param \DateTime $date * @return bool */ function isFirstMondayayOfMonth(\DateTime $date) { return (int)$date->format('d') <= 7 && $date->format('l') === 'Monday'; } $day = new \DateTime('2014/3/10'); var_dump(isFirstMondayayOfMonth($day)); $day = new \DateTime('2014/3/3'); var_dump(isFirstMondayayOfMonth($day));

preferences:
36.06 ms | 402 KiB | 5 Q