Get the First Weekday of the Month in PHP

A simple method to return the first weekdsay of a given month and year

getFirstWeekdayInMonth
private function _getFirstWeekdayInMonth($month, $year, $day = 1) 
{
    $dateData = getdate(mktime(null, null, null, $month, $day, $year));
    if (in_array($dateData['wday'], range(1, 5))) {
        return $dateData['mday'];
    }
    return $this->_getFirstWeekdayInMonth($month, $year, ($day+1));
}

$wday = $this->_getFirstWeekdayInMonth(11, 2013);
comments powered by Disqus