n_months = MONTHS_PER_YEAR; } else { throw new Exception("Invalid view: '$view'"); } // Get the start and end dates $this->start_date = (new DateTime())->setDate($this->year, $this->month, 1); $this->start_date->setMonthYearStart($year_start); $this->start_date->setStartFirstSlot(); $this->end_date = clone $this->start_date; $this->end_date->modify('+' . $this->n_months . ' month'); $this->end_date->modify('-1 day'); $this->end_date->setEndLastSlot(); } }