I have a function which returns all the dates between two dates in an array, But I need to exclude Sundays in that array.
public function dateRange($first, $last, $step = '+1 day', $format = 'd/m/Y' ) {
$dates = array();
$current = strtotime($first);
$last = strtotime($last);
while( $current <= $last ) {
$dates[] = date($format, $current);
$current = strtotime($step, $current);
}
return $dates;
}
After excluding the Sundays, I have a table where I will be storing some dates, I need to exclude those dates from the array too.
like, If I enter the date range as 01-05-2012(DD-MM-YYYY) to 10-05-2012, The 06-05-2012 will be Sunday & the date 01-05-2012 & 08-05-2012 will be in the table which I mentioned above, The final out put should be like,
02-05-2012
03-05-2012
04-05-2012
05-05-2012
07-05-2012
09-05-2012
10-05-2012
How to do this in PHP ? I tried some but couldn't find the right way to do it.
I did this same above method in Jquery
For the Sundays part:
For the holidays part:
First you need to load the dates into some kind of array and then loop through the array for each of your dates and check if they match.
I found the answer for my question, Thanks for the people who helped me.
The above code is for removing the holidays & the Sundays in the given range.