3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function isWeekend($date) { return $date->format('N') >= 6; } $periodStartDate = new \DateTime('today'); $periodStartDate = $periodStartDate->modify('-5 days'); $periodEndDate = new \DateTime('today'); $periodEndDate->modify('+1 day'); $period = new \DatePeriod($periodStartDate, \DateInterval::createFromDateString('1 day'), $periodEndDate); foreach ($period as $date) { echo $date->format('Y-m-d'); echo('<br>'); //if ($this->getDayOffInDaysOffByDate($daysOff, $date) || $this->isWeekend($date)) { // $daysCount--; //} }
based on tWdLi
Output for 5.6.0 - 5.6.30, hhvm-3.15.4, 7.0.0 - 7.2.0
2017-06-30<br>2017-07-01<br>2017-07-02<br>2017-07-03<br>2017-07-04<br>2017-07-05<br>