Get the default timezone id for this thread.

@return String id
@throws TimezonesException on error
336843
public static String getThreadDefaultTzid() throws TimezonesException {
    final String id = threadTzid.get();

    if (id != null) {
      return id;
    }
    return getSystemDefaultTzid();
  }
1106480
public function getAllTimezoneFlat()
    {
        $aTimezones = $this->getAllTimezone();
        $aOut       = [];

        foreach ($aTimezones as $sKey => $mValue) {
            if (is_array($mValue)) {
                foreach ($mValue as $subKey => $subValue) {
                    if (is_string($subValue)) {
                        $aOut[$subKey] = $sKey . ' - ' . $subValue;
                    }
                }
            } else {
                $aOut[$sKey] = $mValue;
            }
        }

        return $aOut;
    }
879733
public static function timeZones()
    {
        $timeZones = [];

        $timezone_identifiers = DateTimeZone::listIdentifiers();
        sort($timezone_identifiers);

        $timeZones['UTC'] = Yii::t('podium/view', 'default (UTC)');

        foreach ($timezone_identifiers as $zone) {
            if ($zone != 'UTC') {
                $zoneName = $zone;
                $timeForZone = new DateTime(null, new DateTimeZone($zone));
                $offset = $timeForZone->getOffset();
                if (is_numeric($offset)) {
                    $zoneName .= ' (UTC';
                    if ($offset != 0) {
                        $offset = $offset / 60 / 60;
                        $offsetDisplay = floor($offset) . ':' . str_pad(60 * ($offset - floor($offset)), 2, '0', STR_PAD_LEFT);
                        $zoneName .= ' ' . ($offset < 0 ? '' : '+') . $offsetDisplay;
                    }
                    $zoneName .= ')';
                }
                $timeZones[$zone] = $zoneName;
            }
        }

        return $timeZones;
    }
723785
public function getZone() : ?string 
    {
        if ( ! $this->hasZone()) {
            $this->setZone($this->getDefaultZone());
        }
        return $this->zone;
    }
909314
private function getTimezonesHavingNewDaySinceLastRun()
    {
        $timestamp = $this->lastSuccessRunTimestamp;
        $uniqueTimezones = APISitesManager::getInstance()->getUniqueSiteTimezones();
        $timezoneToProcess = array();
        foreach ($uniqueTimezones as &$timezone) {
            $processedDateInTz = Date::factory((int)$timestamp, $timezone);
            $currentDateInTz = Date::factory('now', $timezone);

            if ($processedDateInTz->toString() != $currentDateInTz->toString()) {
                $timezoneToProcess[] = $timezone;
            }
        }
        return $timezoneToProcess;
    }
14100
private function loadTimezone() {
		
		if (!is_null($this->id) and (is_null($this->tzName) or is_null($this->tzOffset))) {
			
			$this->db->setQuery('SELECT timezone_name, timezone_offset FROM `sessions` WHERE id_user = ?');
			$obj = $this->db->loadObject($this->id);
			$this->tzOffset	= $obj->timezone_offset;
			$this->tzName	= $obj->timezone_name;
			
		}
		
	}
94070
public DateTimeZone getTimeZone()
    {
        return this.attrValues.get(Person.AttrName.TIMZONE) != null
                        ? DateTimeZone.forID(this.attrValues.get(Person.AttrName.TIMZONE))
                        : DateTimeZone.UTC;
    }
870838
public function getSitesIdFromTimezones($timezones)
    {
        Piwik::checkUserHasSuperUserAccess();

        $timezones = Piwik::getArrayFromApiParameter($timezones);
        $timezones = array_unique($timezones);

        $ids = $this->getModel()->getSitesFromTimezones($timezones);

        $return = array();
        foreach ($ids as $id) {
            $return[] = $id['idsite'];
        }

        return $return;
    }
922072
public TimeZone getTimezone() throws CommandExecutionException {
        JSONArray resp = sendToArray("get_timezone");
        String zone = resp.optString(0, null);
        if (zone == null ) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_RESPONSE);
        return TimeZone.getTimeZone(zone);
    }
358506
public static function getTimeZones(): array
	{
		$timeZones = [];

		foreach(static::listIdentifiers() as $timeZone)
		{
			$timeZones[$timeZone] = str_replace('_', ' ', $timeZone);
		}

		return $timeZones;
	}
523916
private void setDefaultTimeZone() {
        String tzName = System.getProperty("use.time.zone");
        if ( tzName == null ) return;   // Use OS/user default.
        //
        // If tzName is bogus, not understood by the JRE,
        // 'getTimeZone' returns GMT.
        //
        TimeZone toSet = TimeZone.getTimeZone( tzName );
        //
        // Set default to whatever was returned.
        //
        TimeZone.setDefault( toSet );
    }
331805
public static function set_default_server_timezone() {
        global $CFG;

        if (!isset($CFG->timezone) or $CFG->timezone == 99 or $CFG->timezone === '') {
            date_default_timezone_set(self::get_default_php_timezone());
            return;
        }

        $current = date_default_timezone_get();
        if ($current === $CFG->timezone) {
            // Nothing to do.
            return;
        }

        if (!isset(self::$goodzones)) {
            // For better performance try do do this without full tz init,
            // because this is called from lib/setup.php file on each page.
            $result = @timezone_open($CFG->timezone); // Ignore error if setting invalid.
            if ($result !== false) {
                date_default_timezone_set($result->getName());
                return;
            }
        }

        // Slow way is the last option.
        date_default_timezone_set(self::get_server_timezone());
    }
526490
protected TimeZone guessTimeZone() {
        // TODO fix using real data
        // for single-zone countries, pick that zone
        // for others, pick the most populous zone
        // for now, just use fixed value
        // NOTE: in a few cases can do better by looking at language.
        // Eg haw+US should go to Pacific/Honolulu
        // fr+CA should go to America/Montreal
        String timezoneString = territory_tzid_hack_map.get(getTerritory());
        if (timezoneString == null) {
            String[] attempt = TimeZone.getAvailableIDs(getTerritory());
            if (attempt.length == 0) {
                timezoneString = "Etc/GMT"; // gotta do something
            } else {
                int i;
                // this all needs to be fixed to use real data. But for now, do slightly better by skipping cruft
                for (i = 0; i < attempt.length; ++i) {
                    if (attempt[i].indexOf("/") >= 0) break;
                }
                if (i > attempt.length) i = 0;
                timezoneString = attempt[i];
            }
        }
        return TimeZone.getTimeZone(timezoneString);
    }
163860
public function timezone()
	{
		$params = array(
			$this->database,
			$this->user,
			$this->password
		);

		return $this->getClient('common')->call('timezone_get', $params);
	}
111019
static java.util.TimeZone findZone(String id) {

        if (id.equals("Z")) {
            return java.util.TimeZone.getTimeZone("GMT+00:00");
        } else if (id.startsWith("UTC")) {
            return java.util.TimeZone.getTimeZone("GMT" + id.substring(3));
        } else if (id.startsWith("UT")) {
            return java.util.TimeZone.getTimeZone("GMT" + id.substring(2));
        } else {
            return java.util.TimeZone.getTimeZone(id);
        }

    }
1119091
public function inTimezone(string $timeZoneId) : TimezonedDateTime
    {
        return new TimezonedDateTime(
                \DateTimeImmutable::createFromFormat(
                        self::DISPLAY_FORMAT,
                        $this->format(self::DISPLAY_FORMAT),
                        new \DateTimeZone($timeZoneId)
                )
        );
    }
737599
protected static function getTimezoneObject($tz)
    {
        // If the time zone object is not set, attempt to build it.
        if (!($tz instanceof \DateTimeZone)) {
            if ($tz === null) {
                $tz = static::useServerDefaultTimezone() ? self::$stz : self::$gmt;
            } elseif (is_string($tz)) {
                $tz = new \DateTimeZone($tz);
            } elseif ($tz === static::TZ_LOCALE) {
                $config = Ioc::getConfig();
                $tz     = $config->get('system.timezone');
                $tz     = new \DateTimeZone($tz);
            }
        }

        return $tz;
    }