Returns server timezone.
@return string normalised timezone name compatible with PHP
962891
public static function get_server_timezone() {
        global $CFG;

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

        return self::normalise_timezone($CFG->timezone);
    }
533885
public function getTimezone()
    {
        if(!$timezone = $this->getUser()->getTimezone())
        {
            if($timezones = $this->getTimezones()) {
                $timezone = $timezones[0];
            } else {
                $timezone = $this->getConfig()->timezone;
            }
        }

        return $timezone;
    }
996096
public static function getDateTime()
    {
        $dt = \DateTime::createFromFormat('U.u', microtime(true));
        $dt->setTimezone(new \DateTimeZone(date('e')));

        return $dt;
    }
499892
final public function time() {
		if ($this->dbtype == 'pgsql')
			return $this->query(
				"SELECT EXTRACT('epoch' from CURRENT_TIMESTAMP) AS now"
			)['now'];
		if ($this->dbtype == 'mysql')
			return $this->query(
				"SELECT UNIX_TIMESTAMP() AS now")['now'];
		return $this->query(
			"SELECT strftime('%s', CURRENT_TIMESTAMP) AS now"
		)['now'];
	}
639883
public static function getAll()
    {
        $timezones = [];
        $identifiers = DateTimeZone::listIdentifiers();
        foreach ($identifiers as $identifier) {
            $date = new DateTime("now", new DateTimeZone($identifier));
            $offsetText = $date->format("P");
            $offsetInHours = $date->getOffset() / 60 / 60;
            $timezones[] = [
                "identifier" => $identifier,
                "name" => "(GMT{$offsetText}) $identifier",
                "offset" => $offsetInHours
            ];
        }

        ArrayHelper::multisort($timezones, "offset", SORT_ASC, SORT_NUMERIC);
        return $timezones;
    }
262580
public function getServerType()
    {
        $serverSoft = $_SERVER['SERVER_SOFTWARE'];

        preg_match('/^(.*?)\//i', $serverSoft, $match);
        if (empty($match[1])) {
            preg_match('/^(.*)\/?/i', $serverSoft, $match);
        }
        $serverName = strtolower( trim($match[1]) );

        return $serverName;
    }
584039
protected function serverHostname()
    {
        $result = 'localhost.localdomain';
        if (!empty($this->Hostname)) {
            $result = $this->Hostname;
        } elseif (isset($_SERVER) and array_key_exists('SERVER_NAME', $_SERVER) and !empty($_SERVER['SERVER_NAME'])) {
            $result = $_SERVER['SERVER_NAME'];
        } elseif (function_exists('gethostname') && gethostname() !== false) {
            $result = gethostname();
        } elseif (php_uname('n') !== false) {
            $result = php_uname('n');
        }
        return $result;
    }
746560
public function getDateTime() {
    $result = new \DateTime();
    $result->setTimestamp((double) $this->pb->getTime() / 1e6);
    return $result;
  }
467029
private function getDateTime()
    {
        $timezone = new \DateTimeZone($this->options['timezone']);
        $dateTime = new \DateTime('now');
        $dateTime->setTimezone($timezone);
        return $dateTime;
    }
163860
public function timezone()
	{
		$params = array(
			$this->database,
			$this->user,
			$this->password
		);

		return $this->getClient('common')->call('timezone_get', $params);
	}
361399
public function getTimezones()
    {
        $country   = locale_get_region($this->getLanguage());
        $timezones = timezone_identifiers_list(\DateTimeZone::PER_COUNTRY, $country);

        return $timezones;
    }
218243
public function getTimezone() : ?string 
    {
        if ( ! $this->hasTimezone()) {
            $this->setTimezone($this->getDefaultTimezone());
        }
        return $this->timezone;
    }
243501
public function serverDatetime($serverDatetimeOrTimestamp = null) {
		return $this->format($serverDatetimeOrTimestamp, self::ISO_DATETIME_FORMAT, $this->serverTimezone);
	}
1227523
public function getTimezoneDisplayName($timezone)
    {
        $displayName = '';
        if (is_object($timezone)) {
            if ($timezone instanceof \DateTimeZone) {
                $displayName = $timezone->getName();
            } elseif ($timezone instanceof \DateTime) {
                $displayName = $timezone->getTimezone()->getName();
            }
        } elseif (is_string($timezone)) {
            $displayName = $timezone;
        }
        if (strlen($displayName) > 0) {
            $timezones = $this->getTimezones();
            if (array_key_exists($displayName, $timezones)) {
                $displayName = $timezones[$displayName];
            }
        }

        return $displayName;
    }
243008
public function getDateTimeZone(): \DateTimeZone {
	
		$this->loadTimezone();
	
		// tzName is still NULL for guest users
		return new \DateTimeZone($this->tzName ? $this->tzName : BASE_TIMEZONE);
	
	}
694584
public function TimezoneToInterval()
	{
		// Get the timezone
		$timezone = $this->Value->getTimezone()->getName();

		// No deviation returns an empty sequence
		if ( $timezone == "Z" || $timezone == "+00:00" || $timezone == date_default_timezone_get() )
		{
			return DayTimeDurationValue::Parse( "PT0S" );
			// /MinimalConformance/Functions/DurationDateTimeFunc/ComponentExtractionDDT
			// K-TimezoneFromDateFunc-7
			// return Undefined::getValue();
		}

		// Create an interval string
		if ( ! preg_match( "/(?<sign>[+-])(?<hours>\d{2,2}):(?<minutes>\d{2,2})/", $timezone, $matches ) )
		{
			return Undefined::getValue();
		}

		$invert = $matches['sign'] == '-' ? '-' : '';

		return DayTimeDurationValue::Parse( "{$invert}PT{$matches['hours']}H{$matches['minutes']}M" );

	}
1040141
public function get_timezone()
    {
        if ($tz = $this->get('timezone')) {
            try {
                $tz = new DateTimeZone($tz);
                return $tz->getOffset(new DateTime('now')) / 3600;
            }
            catch (Exception $e) {
            }
        }

        return 0;
    }