What I am Trying
I am able to get the number of sat&sun between two dates. What I want is to get the number of sat&sun for each month between those dates.
Suppose start_date is 4-Jul-2015 and end_date is 30-Aug-2015. Then there is 8 sat&sun in Jul and 10 in Aug.
From what I did I'm getting 18. But I need to get 8 and 10. How can I get this ?
Code
$countSat = 0;
$countSun = 0;
$start = new DateTime($_POST['start']);
$end = new DateTime($_POST['end']);
$interval = DateInterval::createFromDateString('1 day');
$period = new DatePeriod($start, $interval, $end);
foreach ($period as $dt)
{
if ($dt->format('N') == 7)
{
$countSun++;
}
if ($dt->format('N') == 6)
{
$countSat++;
}
}
$count = $countSat + $countSun;