Convenience method returning the part's DateTime object.

@return \DateTime
764160
public function getDateTime()
    {
        if (!empty($this->parts) && $this->parts[0] instanceof DatePart) {
            return $this->parts[0]->getDateTime();
        }
        return null;
    }
1370281
private function getDateFromOpenGraph(): ?\DateTime {
        $dt = null;

        $og_data = $this->article()->getOpenGraph();

        try {
            if (isset($og_data['published_time'])) {
                $dt = new \DateTime($og_data['published_time']);
            }
            if (is_null($dt) && isset($og_data['pubdate'])) {
                $dt = new \DateTime($og_data['pubdate']);
            }
        }
        catch (\Exception $e) {
            // Do nothing here in case the node has unrecognizable date information.
        }

        return $dt;
    }
862439
public function getDatePeriod()
    {
        return new \DatePeriod($this->begin, $this->begin->diff($this->end), $this->end);
    }
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;
    }
933747
public static function getTimestamp() {
        $time = microtime(true);
        $microseconds = sprintf('%06d', ($time - floor($time)) * 1000000);
        $millseconds = round($microseconds, -3)/1000;
        $millsecondsStr = str_pad($millseconds, 3, '0', STR_PAD_LEFT);
        $date = (new \DateTime(null, new \DateTimeZone("UTC")))->format('c');

        $position = strrpos($date, '+');
        $date = substr($date,0,$position).'.'.$millsecondsStr.substr($date,$position);

        return $date;
    }
399477
protected function getModifiedSince() : \DateTime
    {
        if (is_null($this->since)) {
            $this->since = new \DateTime('@0');
        }

        return $this->since;
    }
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;
    }
922429
protected function dateTime(): DateTimeImmutable
    {
        if ($this->dateTime === null) {
            $year = $this->year();
            $month = $this->month();
            $day = $this->day();
            $hour = $this->hour();
            $minute = $this->minute();
            $second = $this->second();
            $timezone = $this->timezone()->toString();
            $this->dateTime = self::createNative($year, $month, $day, $hour, $minute, $second, $timezone);
        }

        return $this->dateTime;
    }
1149447
public function getModifiedAt() {
		$timestamp = filemtime($this->pathname);
		$time = new DateTime();
		$time->setTimestamp($timestamp);
		return $time;
	}
56277
public function earnedDate() : ?\DateTime
    {
        if (!$this->earned()) return null;

        return new \DateTime(
            $this->comparing() ?
            $this->trophy->comparedUser->earnedDate :
            $this->trophy->fromUser->earnedDate
        );
    }
420928
private function getEventStartDate()
    {
        $currentDate = $this->Event()->getController()->CurrentDate();
        if ($currentDate && $currentDate->exists()) {
            $date = $currentDate->obj('StartDate')->Format('Y-m-d');
            $time = $currentDate->obj('StartTime')->Format('H:i:s');
            $dateTime = SS_Datetime::create();
            $dateTime->setValue("$date $time");
            return $dateTime;
        } else {
            return null;
        }
    }
436041
public function getDateActive() : ?DateTime
     {
        $rtn = $this->data['date_active'];

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

        return $rtn;
     }
1183500
public function getLogDate() : DateTime
     {
        $rtn = $this->data['log_date'];

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

        return $rtn;
     }
1039289
public function getDataOcorrencia()
    {
        $data = $this->data_de_ocorrencia ? \DateTime::createFromFormat('dmy', sprintf('%06d', $this->data_de_ocorrencia)) : false;
        if ($data) {
            $data->setTime(0, 0, 0);
        }

        return $data;
    }
996096
public static function getDateTime()
    {
        $dt = \DateTime::createFromFormat('U.u', microtime(true));
        $dt->setTimezone(new \DateTimeZone(date('e')));

        return $dt;
    }
726183
public function getTime()
    {
        // Time should only be used with the history state.
        if (!$this->isHistory()) {
            return new DateTime('now');
        }

        $timestamp = $this->session->get($this->timePersistenceKey, time());

        return (new DateTime())->setTimestamp($timestamp);
    }
141279
public function toNativeDateTime()
    {
        $year   = $this->getDate()->getYear()->toNative();
        $month  = $this->getDate()->getMonth()->getNumericValue();
        $day    = $this->getDate()->getDay()->toNative();
        $hour   = $this->getTime()->getHour()->toNative();
        $minute = $this->getTime()->getMinute()->toNative();
        $second = $this->getTime()->getSecond()->toNative();

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

        return $dateTime;
    }