Sets the current date timezone

@link	http://php.net/manual/en/datetime.settimezone.php

@param  string|DateTimeZone $timezone
@return $this
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;
	}
1229941
public function setDateByTimezone($timezone) {
    if (is_string($timezone)) {
      $timezone = new DateTimeZone($timezone);
    }
    $this->convertedTimezone = $timezone;
    $new_date_utc = $this->date->getTimeStamp() - $timezone->getOffset($this->date);
    $new_date = new DateTime();
    $new_date->setTimestamp($new_date_utc);
    $this->date = $new_date;
  }
796930
def SetTimezone(self, timezone):
    
    if not timezone:
      return

    try:
      self._timezone = pytz.timezone(timezone)
    except pytz.UnknownTimeZoneError:
      raise ValueError('Unsupported timezone: {0:s}'.format(timezone))
1006660
public function getUpdated(\DateTimeZone $timezone = null): ?\DateTime
    {
        if (!is_null($timezone)) {
            $returnDate = clone $this->updated;
            $returnDate->setTimeZone($timezone);
            return $returnDate;
        }
        return $this->updated ?? null;
    }
657875
public function format($format, $timezone)
    {
        $date = clone $this->date;
        $date->setTimezone(new DateTimeZone($timezone));
        return $date->format($format);
    }
433910
public static function now(TimeZone $timeZone, Clock $clock = null) : LocalTime
    {
        return ZonedDateTime::now($timeZone, $clock)->getTime();
    }
15824
public function setDefault($timeZone): void
    {
        if (is_string($timeZone) || $timeZone instanceof DateTimeZone) {
            $timeZone = $this->getTimeZone($timeZone);
        }
        $this->timeZoneClass->setDefault($timeZone);
        self::$defaultTz = $timeZone;
    }
215136
public static function now(TimeZone $timeZone, Clock $clock = null) : ZonedDateTime
    {
        return ZonedDateTime::ofInstant(Instant::now($clock), $timeZone);
    }
67651
public function date($timezone = null): Carbon
    {
        $carbon = Carbon::instance($this->transaction->createdAt);

        return $timezone ? $carbon->setTimezone($timezone) : $carbon;
    }
964884
private static function _createTimeZone(string $tz): \DateTimeZone
    {
        try {
            return new \DateTimeZone($tz);
        } catch (\Exception $e) {
            throw new \UnexpectedValueException("Invalid timezone.", 0, $e);
        }
    }
38906
public static function now(?string $timezone = null): Time
    {
        $timezone = $timezone ?: date_default_timezone_get();
        assert(Validate::isTimezone($timezone), sprintf('Invalid timezone: %s', $timezone));

        $dateTime = new DateTimeImmutable('now', new DateTimeZone($timezone));
        $hour = (int) $dateTime->format('G');
        $minute = (int) $dateTime->format('i');
        $second = (int) $dateTime->format('s');

        return new static($hour, $minute, $second);
    }
1205436
public static function factory($time = null, $timezone = null) {
        $timezone = static::timezone($timezone);

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

        if (is_numeric($time)) {
            $time = '@' . $time;
        }

        $dt = new DateTime($time);
        $dt->setTimezone($timezone);

        return $dt;
    }
1041556
public static function ofInstant(Instant $instant, TimeZone $timeZone) : ZonedDateTime
    {
        $dateTimeZone = $timeZone->toDateTimeZone();

        // We need to pass a DateTimeZone to avoid a PHP warning...
        $dateTime = new \DateTime('@' . $instant->getEpochSecond(), $dateTimeZone);

        // ... but this DateTimeZone is ignored because of the timestamp, so we set it again.
        $dateTime->setTimezone($dateTimeZone);

        $localDateTime = LocalDateTime::parse($dateTime->format('Y-m-d\TH:i:s'));
        $localDateTime = $localDateTime->withNano($instant->getNano());

        if ($timeZone instanceof TimeZoneOffset) {
            $timeZoneOffset = $timeZone;
        } else {
            $timeZoneOffset = TimeZoneOffset::ofTotalSeconds($dateTime->getOffset());
        }

        return new ZonedDateTime($localDateTime, $timeZoneOffset, $timeZone, $instant);
    }
1269248
private function offsetSeconds(string $timezone): float
    {
        $dtz = new DateTimeZone($timezone);

        return $dtz->getOffset(new DateTime('now', $dtz));
    }
506621
public final void setTimeZone(final TimeZone timeZone) {
        for (final Period period : this) {
            period.setTimeZone(timeZone);
        }
        this.timezone = timeZone;
        this.utc = false;
    }
785079
public function datetime($datetime, $timezone = null, $format = 'M/d/Y - h:i:s A')
    {
        $datetime = new \DateTime($datetime);

        if($timezone) {

            $datetime->setTimezone(new \DateTimeZone($timezone));
        }

        return $datetime->format($format); 
    }
1284578
final public function onTimeZone(string $timeZoneCode): self
    {
        if (\in_array($timeZoneCode, \timezone_identifiers_list())) {
            $this->requestHeaderTimezoneCode = $timeZoneCode;
        }

        return $this;
    }