@param int $timeStamp

@return \DateTime
972539
protected function createDateTime($timeStamp)
    {
        $date = \DateTime::createFromFormat('U', $timeStamp);

        if ($tz = $this->getTimeZone()) {
            $date->setTimezone($tz);
        }

        return $date;
    }
724399
public static function fromTimestampWithMicroseconds(int $timestamp) : self
    {
        $seconds      = (int)($timestamp / 10 ** 6);
        $microseconds = $timestamp - ($seconds * 10 ** 6);

        // Ensure microseconds are right-padded with zeros because values like 012345 will be 12345 when expressed
        // as an integer, and the concatenation below will therefore shift digits left by one place.
        $microseconds = str_pad($microseconds, 6, '0', STR_PAD_LEFT);
        
        return static::fromFormat('U.u', $seconds . '.' . $microseconds);
    }
64901
public static function getISO8601($timestamp=false) {
        if ( $timestamp === false ) {
            $dt = new \DateTime();
        } else {
            $format = 'Y-m-d H:i:s';
            $dt = \DateTime::createFromFormat($format, $timestamp);
        }

        // 2017-08-16T16:26:31-1000
        $iso8601 = $dt->format(\DateTime::ISO8601);

        // 2017-08-20T10:34:05.000Z
        $iso8601 = str_replace('-1000','.000Z',$iso8601);

        return $iso8601;
    }
306758
public static function shortDate($timestamp = null)
    {
        $l = self::getLocale();
        $cYear = date('Y');
        $date = date('Y-m-d', $timestamp);
        if (date('Y-m-d') == $date) {
            return I18n::get('Today %1', self::formatTime($timestamp));
        } elseif (date('Y-m-d', strtotime('yesterday')) == $date) {
            return I18n::get('Yesterday %1', self::formatTime($timestamp));
        } elseif (date('Y-m-d', strtotime('tomorrow')) == $date) {
            return I18n::get('Tomorrow %1', self::formatTime($timestamp));
        } elseif ($cYear == date('Y', $timestamp)) {
            return self::date(I18n::get('F j'), $timestamp);
        } else {
            return self::date(I18n::get('F Y'), $timestamp);
        }
    }
64808
private function timeAgo($timestamp) {
    $now = new \DateTime('now');
    $date = new \DateTime();
    $date->setTimestamp($timestamp);
    $datediff = date_diff($now, $date);
    $message = '';
    $components = [
      ['y', 'year', 'years'], ['m', 'month', 'months'],
      ['d', 'day', 'days'], ['h', 'hour', 'hours'],
      ['i', 'minute', 'minutes'], ['s', 'second', 'seconds'],
    ];
    foreach ($components as $component) {
      if ($datediff->{$component[0]} > 0) {
        $message = $datediff->{$component[0]} . ' '
          . ($datediff->{$component[0]} > 1 ? t($component[2]) : $component[1]);
        break;
      }
    }
    return !empty($message) ? $message . ' ' . t('ago') : '';
  }
734268
public static function formatOther($timestamp, $format = 'eeee')
    {
        $instance=self::$_instance;
        $fmt=new IntlDateFormatter($instance->_currentLocale, 0, 0);
        $fmt->setPattern($format);
        return $fmt->format($timestamp);
    }
803826
public static function timestampToGermanDateFormat(int $timestamp): string {
        $dateTime = new \DateTime();
        $dateTime->setTimestamp($timestamp);
        $format = $dateTime->format(DateTimeUtil::GERMAN_DATE_TIME_FORMAT);
        return $format;
    }
679115
public static function dateTime ($date, $timestamp = FALSE) {
		return ($timestamp) ? date('c',$date) : date('c', strtotime($date));
	}
66002
public function setTimestamp($timestamp = 0)
    {
        $this->timestamp = $timestamp;
        if ($timestamp === 0) {
            $this->timestamp = $this->generateTimestamp();
        }
        return $this;
    }
875901
public static function isoDate($timestamp = null)
    {
        $tz = date_default_timezone_get();
        date_default_timezone_set('UTC');

        if (is_null($timestamp)) {
            $timestamp = time();
        }

        $returnValue = str_replace(
            '+00:00', '.0000000Z', date('c', $timestamp)
        );
        date_default_timezone_set($tz);

        return $returnValue;
    }
549292
public static function createDateTimeFromTimestampWithMilliseconds($timestamp)
    {
        // manage negative timestamps (before unix epoch)
        if ($timestamp < 0) {
            $datetime = new \DateTime();
            $datetime = $datetime->setTimestamp($timestamp);
        } else {
            $datetime = \DateTime::createFromFormat('U.u', $timestamp, new \DateTimeZone('UTC'));

            if ($datetime == false) {
                $datetime = \DateTime::createFromFormat('U', $timestamp, new \DateTimeZone('UTC'));
            }
        }

        if ($datetime == false) {
            throw new \RuntimeException(
                sprintf('Could not create datetime from "%s": %s',
                    $timestamp,
                    print_r(\DateTime::getLastErrors(), true)
                )
            );
        }

        return $datetime;
    }
951193
function setTimestamp(?int $timestamp = null) {
        $this->timestamp = (new \DateTime(($timestamp !== null ? '@'.$timestamp : 'now')))->format('c');
        return $this;
    }
837675
public static function longDate($timestamp = null)
    {
        $l = self::getLocale();
        return self::date($l->shortDateTime, $timestamp);
    }
1048934
public function setDateFromTimeStamp($timestamp, DateTimeZone $dateTimeZone) {
    $dateTimeZone = !empty($dateTimeZone) ? $dateTimeZone : new DateTimeZone('UTC');
    $this->date = new DateTime('now');
    $this->date->setTimestamp($timestamp);
    $this->date->setTimezone($dateTimeZone);
  }
380385
public function setTimestamp( $timestamp ) {
		$instance = parent::setTimestamp( $timestamp );
		list(
			$instance->arYear,
			$instance->arMonth,
			$instance->arDay
			) = ( new Date() )->hjConvert( $instance->year, $instance->month, $instance->day );
		
		return $instance;
	}
457674
public static function fromTimestamp(int $timestamp, ?string $timezone = null): Time
    {
        $timezone = $timezone ?: date_default_timezone_get();
        assert(Validate::isTimezone($timezone), sprintf('Invalid timezone: %s', $timezone));

        $time = sprintf('%d', $timestamp);
        $dateTime = DateTimeImmutable::createFromFormat('U', $time, new DateTimeZone('UTC'));
        $dateTime = $dateTime->setTimezone(new DateTimeZone($timezone));
        $hour = (int) $dateTime->format('G');
        $minute = (int) $dateTime->format('i');
        $second = (int) $dateTime->format('s');

        return new static($hour, $minute, $second);
    }
1281946
public function revisionAtTimestamp($timestamp)
    {
        $revision = $this->revisions()
                         ->where('created_at', '<=', Carbon::parse($timestamp))
                         ->first();

        return $this->wrapRevision($revision);
    }