Get date (from headers).

@return null|\DateTimeImmutable
774184
final public function getDate(): ?\DateTimeImmutable
    {
        /** @var null|string $dateHeader */
        $dateHeader = $this->getHeaders()->get('date');
        if (null === $dateHeader) {
            return null;
        }

        $alteredValue = $dateHeader;
        $alteredValue = \str_replace(',', '', $alteredValue);
        $alteredValue = (string) \preg_replace('/^[a-zA-Z]+ ?/', '', $alteredValue);
        $alteredValue = (string) \preg_replace('/ +\(.*\)/', '', $alteredValue);
        $alteredValue = (string) \preg_replace('/\bUT\b/', 'UTC', $alteredValue);
        if (0 === \preg_match('/\d\d:\d\d:\d\d.* [\+\-]\d\d:?\d\d/', $alteredValue)) {
            $alteredValue .= ' +0000';
        }

        try {
            $date = new \DateTimeImmutable($alteredValue);
        } catch (\Throwable $ex) {
            throw new InvalidDateHeaderException(\sprintf('Invalid Date header found: "%s"', $dateHeader), 0, $ex);
        }

        return $date;
    }
28888
public function getLastModified(): \DateTime
    {
        if ($this->caching == false) {
            return \DateTime::createFromFormat("F d Y H:i:s.", date("F d Y H:i:s.", filemtime($this->getAbsoluteFilePath())));
        }

        if ($this->lastModified == null) {
            $this->lastModified = \DateTime::createFromFormat("F d Y H:i:s.", date("F d Y H:i:s.", filemtime($this->getAbsoluteFilePath())));
        }

        return $this->lastModified;
    }
386822
public function getFeedExportStartDate()
    {
        $file = new SplFileInfo($this->config->getFeedTmpFile());
        if (!$file->isFile()) {
            return null;
        }

        return new DateTime('@' . $file->getMTime());
    }
1269212
private function getDateTimeType(): Type
    {
        if ($this->dateTimeType === null) {
            $this->dateTimeType = Type::getType(DateTimeType::DATETIME);
        }

        return $this->dateTimeType;
    }
571954
public function getDates()
    {
        $defaults = [static::CREATED_AT, static::UPDATED_AT];

        return $this->timestamps ? array_merge($this->dates, $defaults) : $this->dates;
    }
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;
    }
533505
public function getCreated()
    {
        $date = !is_null($this->created) ? date('d-m-Y H:i', $this->created) : null;

        return new \Datetime($date);
    }
708077
public function getExpires() {
        if (!isset($this->metadata[OSSHeaders::EXPIRES])) {
            return null;
        }
        return DateUtils::parseDate($this->metadata[OSSHeaders::EXPIRES]);
    }
25466
public function getLastRead(): \DateTime
    {
        if ($this->caching == false) {
            return \DateTime::createFromFormat("F d Y H:i:s.", date("F d Y H:i:s.", fileatime($this->getAbsoluteFilePath())));
        }

        if ($this->lastRead == null) {
            $this->lastRead = \DateTime::createFromFormat("F d Y H:i:s.", date("F d Y H:i:s.", fileatime($this->getAbsoluteFilePath())));
        }

        return $this->lastRead;
    }
522929
public function getLastFeedExportDate()
    {
        $file = new SplFileInfo($this->config->getDefaultFeedFile());
        if (!$file->isFile()) {
            return null;
        }

        return new DateTime('@' . $file->getMTime());
    }
805750
public function Date()
    {
        $formatter = $this->getFormatter(IntlDateFormatter::MEDIUM, IntlDateFormatter::NONE);
        return $formatter->format($this->getTimestamp());
    }
1130697
public function getTimestamp()
    {
        $timestamp = $this->runLast('date +"%Y%m%d%H%M%S"');
        $timestamp = trim($timestamp);
        $timestamp = preg_match('/^[0-9]{14}$/', $timestamp) ? $timestamp : date('YmdHis');

        return $timestamp;
    }
241026
public function getLastRefreshTimestamp()
    {
        $unixTime = Cache::get($this->cacheTimestampKey);
        
        $dateTime = new DateTime;
        $dateTime->setTimestamp($unixTime);
        
        return $dateTime;
    }
745317
private function setHeader($header)
    {
        preg_match("'\[(.*?)\] 'si", $header, $match);
        if (!isset($match[1])) {
            throw new Exception('Unable to read datetime from header.');
        }
        $this->setDatetime($match[1]);

        $header = $this->cleanHeader($header);

        if (preg_match('/^[a-z]+.[A-Z]+:/', $header, $out)) {
            $this->setEnv($out[0]);
            $header = trim(str_replace($out[0], '', $header));
        }

        $this->header = $header;

        return $this;
    }
787455
public function getLogoutDate()
    {
        return isset($this->loginData[self::LOGOUT_DATE]) ? $this->loginData[self::LOGOUT_DATE] : null;
    }
961264
public function date(): Date
    {
        if ($this->date === null) {
            $this->date = new Date($this->attribute('DATE'));
        }

        return $this->date;
    }
1161503
public function getDateTime($time = null)
    {
        if(null === $time)
        {
            $time = time();
        }
        return date($this->dateTimeFormat, $time);
    }