public function getPeriod($period, $mode = self::DAYS_ONLY)
    {
        $result = $this->parsePeriod($period);

        if ($result['max'] && $mode == self::DAYS_AND_TIME) {
            $result['max']->modify("+1 day -1 second");
        }

        foreach ($result as $key => $value) {
            if (!$value) {
                unset($result[$key]);
            } elseif ($mode == self::DAYS_ONLY) {
                $result[$key] = new DateTime($result[$key]->format('Y-m-d'), $this->getTimezoneTo());
            } elseif ($this->getTimezoneTo()) {
                $result[$key]->setTimezone($this->getTimezoneTo());
            }
        }

        return $result;
    }
public function getPeriod($period, $mode = self::DAYS_ONLY)
    {
        $result = $this->parsePeriod($period);

        if ($result['max'] && $mode == self::DAYS_AND_TIME) {
            $result['max']->modify("+1 day -1 second");
        }

        foreach ($result as $key => $value) {
            if (!$value) {
                unset($result[$key]);
            } elseif ($mode == self::DAYS_ONLY) {
                $result[$key] = new DateTime($result[$key]->format('Y-m-d'), $this->getTimezoneTo());
            } elseif ($this->getTimezoneTo()) {
                $result[$key]->setTimezone($this->getTimezoneTo());
            }
        }

        return $result;
    }
public function getPeriod ( $ period , $ mode = self :: DAYS_ONLY ) { $ result = $ this -> parsePeriod ( $ period ) ; if ( $ result [ 'max' ] && $ mode == self :: DAYS_AND_TIME ) { $ result [ 'max' ] -> modify ( "+1 day -1 second" ) ; } foreach ( $ result as $ key => $ value ) { if ( ! $ value ) { unset ( $ result [ $ key ] ) ; } elseif ( $ mode == self :: DAYS_ONLY ) { $ result [ $ key ] = new DateTime ( $ result [ $ key ] -> format ( 'Y-m-d' ) , $ this -> getTimezoneTo ( ) ) ; } elseif ( $ this -> getTimezoneTo ( ) ) { $ result [ $ key ] -> setTimezone ( $ this -> getTimezoneTo ( ) ) ; } } return $ result ; }
Calculate min and max dates and return them as DateTime objects.

@param string $period Period name
@param int    $mode   [optional] Period::DAYS_AND_TIME or Period::DAYS_ONLY

@return DateTime[]
@throws Exception If unable to determine the period.
Calculate min and max dates and return them as DateTime objects .