-1
Because this code does not show the last day of the month?
$whiteDays = ["Monday", "Tuesday", "Wednesday", "Thursday", "Saturday", "Sunday", "Friday"];
$year = 2020;
$month = 4;
$from = new DateTimeImmutable("$year-$month");
$to = $from->modify('last day of this month');
$datePeriod = new DatePeriod($from, DateInterval::createFromDateString('1 day'), $to);
$dates = iterator_to_array($datePeriod);
$filtered = array_filter($dates, function (DateTimeImmutable $day) use ($whiteDays) {
if (in_array($day->format('l'), $whiteDays)) {
return true;
}
});
I need to return all the coded dates to valid $whiteDays
.
When I run, I have a list but never the last day of the month appears, which can be?