Returns the Date header as a DateTime instance.

@return \DateTime A \DateTime instance

@throws \RuntimeException When the header is not parseable

@final since version 3.2
327514
public function getDate()
    {
        /*
            RFC2616 - 14.18 says all Responses need to have a Date.
            Make sure we provide one even if it the header
            has been removed in the meantime.
         */
        if (!$this->headers->has('Date')) {
            $this->setDate(\DateTime::createFromFormat('U', time()));
        }

        return $this->headers->getDate('Date');
    }
1118682
public function getRuntimePath()
    {
        if ($this->_runtimePath === null) {
            $this->_runtimePath = $this->getAlias('@runtime');
        }

        return $this->_runtimePath;
    }
214660
public function getExecutionTime()
    {
        if(!$this->getFinishedAt()) {
            $now = new \DateTime();
            return $now->getTimestamp() - $this->getCreatedAt()->getTimestamp();
        } else {
            return $this->getFinishedAt()->getTimestamp() - $this->getCreatedAt()->getTimestamp();
        }
    }
29246
public function toNativeDateTime()
    {
        $date     = $this->getDateTime()->getDate();
        $time     = $this->getDateTime()->getTime();
        $year     = $date->getYear()->toNative();
        $month    = $date->getMonth()->getNumericValue();
        $day      = $date->getDay()->toNative();
        $hour     = $time->getHour()->toNative();
        $minute   = $time->getMinute()->toNative();
        $second   = $time->getSecond()->toNative();
        $timezone = $this->getTimeZone()->toNativeDateTimeZone();

        $dateTime = new \DateTime();
        $dateTime->setTimezone($timezone);
        $dateTime->setDate($year, $month, $day);
        $dateTime->setTime($hour, $minute, $second);

        return $dateTime;
    }
228843
private function currentDateTime()
    {
        $dateTime = \DateTime::createFromFormat('U.u', sprintf('%.6F', microtime(true)));
        $dateTime->setTimezone(new \DateTimeZone(date_default_timezone_get()));

        return $dateTime;
    }
528494
public function getAge()
    {
        if (!$age = $this->_headers->get('Age', 0)) {
            $age = max(time() - $this->getDate()->format('U'), 0);
        }

        return $age;
    }
467029
private function getDateTime()
    {
        $timezone = new \DateTimeZone($this->options['timezone']);
        $dateTime = new \DateTime('now');
        $dateTime->setTimezone($timezone);
        return $dateTime;
    }
443204
public function xml()
    {
        try {
            // Allow XML to be retrieved even if there is no response body
            $xml = new \SimpleXMLElement((string) $this->body ?: '<root />');
        } catch (\Exception $e) {
            throw new RuntimeException('Unable to parse response body into XML: ' . $e->getMessage());
        }

        return $xml;
    }
739160
public function tell()
    {
        if (!$this->stream) {
            throw new RuntimeException('No stream');
        }

        $position = ftell($this->stream);
        if (!$position) {
            throw new RuntimeException('Cannot get current position');
        }

        return $position;
    }
337115
public function getNewrelicBrowserTimingHeader(): string
    {
        if ($this->isHeaderCalled()) {
            throw new \RuntimeException('Function "ekino_newrelic_browser_timing_header" has already been called');
        }

        $this->prepareInteractor();

        $this->headerCalled = true;

        return $this->interactor->getBrowserTimingHeader();
    }
510439
public function objType()
    {
        if ($this->objType === null) {
            throw new RuntimeException(sprintf(
                'Missing object type ("obj_type"). Invalid property "%s".',
                $this->ident()
            ));
        }

        return $this->objType;
    }
1257113
final public static function now()
    {
        if (self::$now === null) {
            try {
                self::$now = new \DateTimeImmutable('now', self::tzUtc());
            } catch (\Exception $e) {
                return null;
            }
        }

        return self::$now;
    }
280559
public function getBadPasswordDate()
    {
        if ($timestamp = $this->getBadPasswordTimestamp()) {
            return (new DateTime())->setTimestamp($timestamp)->format($this->dateFormat);
        }
    }
1270654
public static function dateTimeFormat()
    {
        return self::pickOne(array(
            DATE_ATOM,
            DATE_COOKIE,
            DATE_ISO8601,
            DATE_RFC822,
            DATE_RFC850,
            DATE_RFC1036,
            DATE_RFC1123,
            DATE_RFC2822,
            DATE_RSS,
            DATE_W3C,
        ));
    }
77332
public function getDateAdded() : ?DateTime
     {
        $rtn = $this->data['date_added'];

        if (!empty($rtn)) {
            $rtn = new DateTime($rtn);
        }

        return $rtn;
     }
468410
protected static function getDateTime()
    {
        // Lazyload
        if (null === self::$dateTime) {
            /* @var Doozr_Datetime_Service self::$dateTime */
            self::$dateTime = Doozr_Loader_Serviceloader::load('datetime');
        }

        return self::$dateTime;
    }
621890
private function getDateFromDublinCore(): ?\DateTime {
        $dt = null;
        $nodes = $this->article()->getRawDoc()->find('*[name="dc.date"], *[name="dc.date.issued"], *[name="DC.date.issued"]');

        /* @var $node Element */
        foreach ($nodes as $node) {
            try {
                if ($node->hasAttribute('content')) {
                    $dt = new \DateTime($node->getAttribute('content'));
                    break;
                }
            }
            catch (\Exception $e) {
                // Do nothing here in case the node has unrecognizable date information.
            }
        }

        if (!is_null($dt)) {
            return $dt;
        }

        return $dt;
    }