Creates a new \DateTimeImmutable instance from provided timestamp and timezone identifiers.

Current timestamp and timezones are used if not provided.
323206
public static function createFromTimestamp(?int $timestamp = null, ?string $timeZone = null): DateTimeInterface
    {
        $dateTimeZone = is_string($timeZone) ? new DateTimeZone($timeZone) : null;
        $timestamp = is_int($timestamp) ? $timestamp : time();

        $dateTime = new DateTimeImmutable('now', $dateTimeZone);

        return $dateTime->setTimestamp($timestamp);
    }
838682
protected function createDateTime($timestamp)
    {
        $dateTime = new \DateTime();
        $dateTime->setTimestamp($timestamp);
        $dateTime->setTimezone($this->dateTimeZone);

        return $dateTime;
    }
329711
function clone(inst, alts) {
  const current = {
    ts: inst.ts,
    zone: inst.zone,
    c: inst.c,
    o: inst.o,
    loc: inst.loc,
    invalid: inst.invalid
  };
  return new DateTime(Object.assign({}, current, alts, { old: current }));
}
1280481
private static function getFixedImmutableTimeFromConfiguredTimestamp($time, $timeZone = null)
    {
        $date = new \DateTimeImmutable(sprintf('@%d', self::$timestamp));
        if ('now' !== $time) {
            $date = $date->modify($time);
        }
        if (null !== $timeZone) {
            $date = $date->setTimezone($timeZone);
        }

        if (false === $date) {
            throw new \RuntimeException('An error happened creating the immutable date');
        }

        return $date;
    }
1199861
def utcfromtimestamp(cls, timestamp):
    """"""
    obj = datetime.datetime.utcfromtimestamp(timestamp)
    obj = pytz.utc.localize(obj)
    return cls(obj)
1035940
public function getCreatedAtDatetime(string $timezone = null): ?DateTime
    {
    	if ($this->created_at === null) {
    		return null;
	    }

        return new DateTime($this->created_at, new DateTimeZone($timezone ?? 'UTC'));
    }
1032621
private static ImmutableMap<System,ImmutableList<DateTimeFormatter>> buildDateTimeFormatterMap() {
        return ImmutableMap.of(

                DEFAULT, ImmutableList.<DateTimeFormatter>builder()
                        .addAll(defaultDateTimeFormatter) // another common case
                        .build(),
                ORACLE, ImmutableList.<DateTimeFormatter>builder()
                        .addAll(defaultDateTimeFormatter)
                        .add(new DateTimeFormatterBuilder().parseCaseInsensitive().appendPattern("dd-MMM-yy[ hh[.][:]mm[.][:]ss[.][,][n][ a][ ZZZZZ][ VV]]").toFormatter())
                        .add(new DateTimeFormatterBuilder().parseCaseInsensitive().appendPattern("dd-MMM-yy[ HH[.][:]mm[.][:]ss[.][,][n][ ZZZZZ][ VV]]").toFormatter())
                        .build(),
                MSSQL, ImmutableList.<DateTimeFormatter>builder()
                        .addAll(defaultDateTimeFormatter)
                        .add(new DateTimeFormatterBuilder().parseCaseInsensitive().appendPattern("MMM dd yyyy[ hh:mm[a]]").toFormatter())
                        .build()
        );
    }
905267
static function makeDateTime(int $timestamp) {
        $zone = new \DateTimeZone(\date_default_timezone_get());
        return (new \DateTime('@'.$timestamp))->setTimezone($zone);
    }
757933
def from_timestamp(timestamp, tz_offset):
    """"""
    utc_dt = datetime.fromtimestamp(timestamp, utc)
    try:
        local_dt = utc_dt.astimezone(tzoffset(tz_offset))
        return local_dt
    except ValueError:
        return utc_dt
896519
public static function fromFormat(string $format, string $dateString, string $timeZoneId) : TimezonedDateTime
    {
        return new self(\DateTimeImmutable::createFromFormat('!' . $format, $dateString, new \DateTimeZone($timeZoneId)));
    }
939306
public static function createFromFormat($format, $datetime, $timezone = null)
    {
        $datepoint = parent::createFromFormat($format, $datetime, $timezone);
        if (false !== $datepoint) {
            return self::create($datepoint);
        }

        return $datepoint;
    }
951275
public static function factory($time = null, string $timezone = null): \DateTime
    {
        if (! $timezone instanceof \DateTimeZone) {
            $timezone = $timezone ?: date_default_timezone_get();
            $timezone = new \DateTimeZone($timezone);
        }

        if ($time instanceof \DateTime) {
            return $time->setTimezone($timezone);
        }

        $datetime = new \DateTime('@' . self::timestamp($time));
        return $datetime->setTimezone($timezone);
    }
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);
    }
274677
public function fromUrl(string $param)
    {
        if ($this->checkDate($param)) {
            return new \DateTimeImmutable($param, $this->timezone);
        }

        throw $this->newInvalidFromUrl($param);
    }
191552
def new_datetime(self):
        """"""
        from datetime import datetime

        try:
            return datetime.fromtimestamp(self.state.new)
        except TypeError:
            return None
123716
private SimpleDateFormat createDateTimeTimeZoneFormat() {
		SimpleDateFormat dateTimeTimeZoneFormat = new SimpleDateFormat( DATE_TIME_TIMEZONE_FORMAT );
		dateTimeTimeZoneFormat.setLenient( false );
		return dateTimeTimeZoneFormat;
	}
1245267
def to_unix(cls, timestamp):
        
        if not isinstance(timestamp, datetime.datetime):
            raise TypeError('Time.milliseconds expects a datetime object')
        base = time.mktime(timestamp.timetuple())
        return base