I'm trying to get the count for weekdays and weekends between two dates but for weekends I'm getting 0 value .
Here is the code :
<?php
function daysCount($startDate, $endDate)
{
$weekdayCount = $weekendCount =0;
$startTimestamp = strtotime($startDate);
$endTimestamp = strtotime($endDate);
for ($i = $startTimestamp; $i <= $endTimestamp; $i = $i + (60 * 60 * 24))
{
if (date("N", $i) <= 5)
{
$weekdayCount = $weekdayCount + 1;
}
if (date("N", $i) == 6 && $i%7 == 0 )
{
$weekendCount = $weekendCount + 1;
}
}
return array('weekdayCount' => $weekdayCount, 'weekendCount' => $weekendCount);
}
$startDate = "2017-07-03";
$endDate = "2017-07-10";
$days = daysCount($startDate, $endDate);
print_r($days);
?>
And this is the demo link demo updated
Can somebody help me to get the weekendCount ?