How many saturdays have passed
Moderator: General Moderators
How many saturdays have passed
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!
Re: How many saturdays have passed
Going from the first of the current year, and counting the current week if today is Saturday:
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;
}