How can I calculate the number of Saturdays and Sundays between two dates in php?
Is there any inbuilt function for that purpose?
I searched for awhile for a simple solution that worked and decided to write my own and came up with this
$start = date('Y-m-d');
$end = date('Y-m-d', strtotime($start.' +1 year'));
$current = $start;
$count = 0;
while($current != $end){
if(date('l', strtotime($current)) == 'Saturday'){
$count++;
}
$current = date('Y-m-d', strtotime($current.' +1 day'));
};
echo $count;