i need to put two dates, for example a range dates from 2016-10-01 to 2016-11-01 and generate all saturday and sunday dates in that range.
For example this return:
2016-10-1
2016-10-2
2016-10-8
2016-10-9
2016-10-15
2016-10-16
2016-10-22
2016-10-23
2016-10-29
2016-10-30
NOTE: Not only weekends. For example i have and array like this:
array('monday','saturday','sunday')
I'm try this code, but this not work correctly:
$event_da = '2016-10-01';
$event_a = '2016-11-01';
$weekdays = array('saturday','sunday');
for ( $i = $event_da; $i <= $event_a; $i = $i + 86400 ) {
$thisDate = date( 'Y-m-d', $i );
$getDate = date('l', strtotime($thisDate));
if ( in_array( $getDate, $weekdays) ) {
echo $thisDate;
}
}