I need to get an array of dates except sunday and optional saturday by a specific day count... I found a cool thing - dateperiod, witch gives array to me, but how to exclude sunday and saturday?
Asked
Active
Viewed 128 times
2 Answers
1
Try this...
$daterange = new DatePeriod(...);
$weekdays = [];
foreach($daterange as $date){
if ($date->format("N") < 6) array_push($weekdays, $date);
}
$weekdays
should now contain every date
object that isn't the 6th or greater day of the week (that is, Saturday or Sunday)

Simon M
- 2,931
- 2
- 22
- 37
0
As Simon M says, that seems to be the solution to this issue, it has been answered here too Get date range between two dates excluding weekends
It's a bit disconcerting there's not an option on DatePeriod to exclude days.