Tag Archives: How to Detemine The Number Of Fridays In A Month

How to Detemine The Number Of Fridays In A Month

The following code determines the number of Fridays in a month :

$year = 2008;
$month = 1; //Aug
$day = 1;
$startDate = mktime(0, 0, 0, $month, $day, $year);
$NoD = date( “t”, $startDate);

While(date( “D”, $startDate) != “Fri”) //find first Friday
{
$day++;
$startDate = mktime(0, 0, 0, $month, $day, $year);
}
$day–;
$days = ceil(($NoD-$day)/7);
echo “$days Fridays”;

Replace the $month=1; to the number of the month you want.