>"Liam Gibbs" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >Is there any easy way of figuring out if there are 4 or if there are 5 Fridays in a given month? I have it >figured out using a loop, but I was just wondering if there was a way that date() or strtotime() could >do it.
K - given a month and year of $month, $year: (not really much prettier than a loop...) function num_fridays($month, $year) { $fdom = mktime(0, 0, 0, $month, 1, $year); $wday = date("w", $fdom); // get weekday if ($wday > 5 or $wday < 3) // 5 Fridays impossible. return 4; $lday = date("t", $fdom); // get number of days in the month $buffer = $lday - 28; if ($wday >= (5 - $buffer) and ($wday <= 5)) return 5; else return 4; } This worked for me on a couple test months. -- Rob -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php