I'm using Bootstrap datepicker and I'd like to get special days of every week ( Like: Monday, Wednesday, Saturday). For example, If we select every monday and Wednesday then select only Monday and Wednesday.
And I want this weekday through month wise, (Like, If we select date 24-jun to 24-july and select only Monday. Then every Monday from 24-jun to 24-july will be selected).
So what would be the correct way to get weekdays using bootstrap datepicker?
Any kind of help would be highly appreciated.
Thanks in advance.
I´ve found the solution :
$start_date = "28-06-2016";
$end_date = "28-07-2016";
$weekdays = [1,2]; // 0 = sunday, 1 = monday ...
$range_date = array();
for ($i = strtotime($start_date); $i <= strtotime($end_date); $i = strtotime('+1 day', $i))
{
if(in_array(date('N', $i), $weekdays))//Monday == 1
{
echo date('l Y-m-d', $i).'<br>'; //prints the date only if it's a Monday or tuseday etc..
}
}
And output :
Tuesday 2016-06-28
Monday 2016-07-04
Tuesday 2016-07-05
Monday 2016-07-11
Tuesday 2016-07-12
Monday 2016-07-18
Tuesday 2016-07-19
Monday 2016-07-25
Tuesday 2016-07-26