How many saturdays have passed
Posted: Wed Jan 11, 2012 9:22 pm
Hello! I want to be able to make a code that tells me how many saturdays have passed till today in this month. I've tried a couple of things but nothing. Any help?! Thanks!
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Code: Select all
function numberSaturdays() {
$dowStart = date('w',mktime(0,0,0,1,1,date('Y')));
$dowNow = date('N');
$numSaturdays = date('W');
if (date('m')==1 && $numSaturdays > 50) { $numSaturdays = 0; }
if($dowStart < 5 && $dowNow < 6) { $numSaturdays--; }
elseif($dowStart > 4 && $dowNow > 5) { $numSaturdays++; }
return $numSaturdays;
}