@param int               $timestamp    timestamp like @see time()
@param DateTimeZone|null $dateTimeZone the timezone

@return DateTime the datetime u wanted
185904
public static function fromTimestamp($timestamp, DateTimeZone $dateTimeZone = null)
    {
        $base = new GregorianDateTime(
            date('Y-m-d H:i:s', $timestamp),
            self::checkForDateTimeZone($dateTimeZone)
        );

        return new DateTime($base);
    }
952576
public static function parse($timestamp = null)
    {
        if (static::isMilliseconds($timestamp)) {
            return static::fromMilliseconds($timestamp);
        }

        if ($timestamp instanceof Carbon) {
            return $timestamp;
        }

        return Carbon::parse($timestamp);
    }
1328369
public function getUpdatedAtDatetime(string $timezone = null): ?DateTime
    {
        if (!$this->hasUpdatedAt()) {
            return null;
        }

        if ($timezone === null) {
            $timezone = 'UTC';
        }

        return new DateTime($this->getUpdatedAt(), new DateTimeZone($timezone));
    }
510525
public function fromTimestamp($timestamp, $timezone = 'UTC')
    {
        // [TODO] use DateTime object for parse timestamp
        $oldTz = date_default_timezone_get();
        date_default_timezone_set($timezone);
        $timestamp = mktime(date('H', $timestamp), date('i', $timestamp), date('s', $timestamp), date('n', $timestamp), date('j', $timestamp), date('Y', $timestamp));
        date_default_timezone_set('UTC');
        $utcDT = gmdate('c', $timestamp);
        $dateArray = getdate(strtotime(gmdate('c', $timestamp)));
        date_default_timezone_set($oldTz);
        unset($dateArray[0]);

        $this->from($dateArray, 'en_US', null, $timezone);

        return $this;
    }
771243
public function fromRedisTimestamp($timestamp) : DateTime
    {
        $date = DateTime::createFromFormat('U', $timestamp);
        $date->setTimezone(new DateTimeZone(date_default_timezone_get()));

        return $date;
    }
1077590
public static function formatStartsAt($timestamp)
    {
        $tz = date_default_timezone_get();
        date_default_timezone_set('UTC');
        $date = date('c', $timestamp);
        date_default_timezone_set($tz);
        if (!$date) {
            throw new \RuntimeException(sprintf('Failed to format timestamp: %d', $timestamp));
        }

        return $date;
    }
734663
public static function createFromDefaultFormat($datetime, $timezone = null)
    {
        return self::createFromFormat(self::$defaultFormat, $datetime, $timezone);
    }
70696
public static function elapsedTime($timestamp)
    {
        // @todo: deprecated - use timeDiff instead of this

        $dateDiff = self::timeDiff($timestamp);

        unset ($dateDiff['month']);

        $dateDiff['week'] = floor($dateDiff['days_total'] / 7);
        $dateDiff['day']  = $dateDiff['days_total'] % 7;

        return $dateDiff;
    }
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;
	}
585229
public function setTimestamp($timestamp = null)
    {
        $this->timestamp = $timestamp;
        if ($timestamp === null) {
            $this->timestamp = new Timestamp();
        }
        return $this;
    }
974038
static function dateTime(?\DateTimeZone $timezone = null): \DateTime
    {
        if (self::$now !== null) {
            $now = \DateTime::createFromFormat('U.u', sprintf('%.6F', self::$now));
            $now->setTimezone($timezone ?? new \DateTimeZone(date_default_timezone_get()));

            return $now;
        }

        return new \DateTime('now', $timezone);
    }
484435
public static function newImmutablePhpDateTime($time = 'now', \DateTimeZone $timeZone = null)
    {
        if (self::DATETIME_SYSTEM === self::$type) {
            return new \DateTimeImmutable($time, $timeZone);
        }

        if (self::DATETIME_FIXED === self::$type) {
            return self::getFixedImmutableTimeFromConfiguredTimestamp($time, $timeZone);
        }

        $date = self::getFixedImmutableTimeFromConfiguredTimestamp($time, $timeZone);
        $timePassedSinceInstantiation = abs(
            (new \DateTime())->getTimestamp() - self::$offsetTimestamp
        );

        return $date->modify("+{$timePassedSinceInstantiation} seconds");
    }
772021
private static function _createFromTimestamp($timestamp) {
        // Creates an instance of the current class
        $date = new DateMilli();
        // Creates the DateTime PHP object from the given timestamp
        $dateTime = new \DateTime();
        // Check if the given timestamp is a float value (which means it contains milliseconds)
        $intValue = (int) $timestamp;
        $date->_setMilliseconds((float) ($timestamp - $intValue) * 1000);
        $timestamp = $intValue;
        if ($dateTime->setTimestamp($timestamp) === false) {
            throw new DateMilliException('Impossible to create a Date object from the given timestamp value [' . $timestamp . ']');
        }

        // Set the PHP DateTime instance property
        $date->_dateTime = $dateTime;

        return $date;
    }
905267
static function makeDateTime(int $timestamp) {
        $zone = new \DateTimeZone(\date_default_timezone_get());
        return (new \DateTime('@'.$timestamp))->setTimezone($zone);
    }
908204
public function fromMemcachedTimestamp($timestamp) : DateTime
    {
        $date = DateTime::createFromFormat('U', $timestamp);
        $date->setTimezone(new DateTimeZone(date_default_timezone_get()));

        return $date;
    }
185949
public function setTimezone($timezone = null)
	{
		$this->date->setTimezone($timezone === null ? self::$utc : is_string($timezone) ? ($timezone === 'UTC' ? self::$utc : new \DateTimeZone($timezone)) : ($timezone instanceof \DateTimeZone ? $timezone : $timezone->getTimezone()));
		return $this;
	}
612459
public function withTimezone($timezone): DateTime
    {
        return new static(
            $this->date(),
            $this->time(),
            Timezone::create($timezone)
        );
    }