Get the server time zone instance.

@param bool $fallbackToDefault Fallback to the default one if the time zone is not defined?

@throws UserMessageException

@return DateTimeZone
167763
public function getServerTimeZone($fallbackToDefault)
    {
        $timeZoneId = $this->getServerTimeZoneId();
        if ($timeZoneId === '') {
            if (!$fallbackToDefault) {
                throw new UserMessageException(t('The server time zone has not been defined.'));
            }
            $timeZoneId = @date_default_timezone_get() ?: 'UTC';
        }
        try {
            $result = new DateTimeZone($timeZoneId);
        } catch (Exception $x) {
            $result = null;
        }
        if ($result === null) {
            throw new UserMessageException(t('Invalid server time zone: %s', $timeZoneId));
        }

        return $result;
    }
522929
public function getLastFeedExportDate()
    {
        $file = new SplFileInfo($this->config->getDefaultFeedFile());
        if (!$file->isFile()) {
            return null;
        }

        return new DateTime('@' . $file->getMTime());
    }
488269
public function getEmailAddressOfUser(UserInterface $user, $useFallback = true)
    {
        // take users email address
        $userEmail = $user->getEmail();
        if ($userEmail) {
            return $userEmail;
        }

        // fallback: get contacts / accounts main-email
        $contact = $user->getContact();
        if ($useFallback && $contact) {
            return $this->getEmailAddressOfContact($contact);
        }

        return null;
    }
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());
    }
684300
public function getDefaultLocale()
    {
        try {
            return $this->entityManager->getRepository(Locale::class)->findOneBy(['msIsDefault' => true]);
        } catch (TableNotFoundException $e) {
            return null;
        }
    }
902643
public function getDefaultValue()
    {
        if (!$this->hasDefaultValue()) {
            return null;
        }

        if ($this->defaultValue instanceof FragmentInterface) {
            //Defined as SQL piece
            return $this->defaultValue;
        }

        if (in_array($this->getAbstractType(), ['time', 'date', 'datetime', 'timestamp'])) {
            return $this->formatDatetime($this->getAbstractType(), $this->defaultValue);
        }

        switch ($this->getType()) {
            case 'int':
                return (int)$this->defaultValue;
            case 'float':
                return (float)$this->defaultValue;
            case 'bool':
                if (is_string($this->defaultValue) && strtolower($this->defaultValue) == 'false') {
                    return false;
                }

                return (bool)$this->defaultValue;
        }

        return (string)$this->defaultValue;
    }
243008
public function getDateTimeZone(): \DateTimeZone {
	
		$this->loadTimezone();
	
		// tzName is still NULL for guest users
		return new \DateTimeZone($this->tzName ? $this->tzName : BASE_TIMEZONE);
	
	}
185046
private function getFallbackLocale($locale = null)
    {
        if ($locale && $this->isLocaleCountryBased($locale)) {
            if ($fallback = $this->getLanguageFromCountryBasedLocale($locale)) {
                return $fallback;
            }
        }

        $locales = $this->getLocales();

        foreach ($locales as $code) {
            if ($this->getTranslationByLocaleKey($code) !== null)
                return $code;
        }

        return app()->make('config')->get('revy.translatable.fallback_locale');
    }
1010329
static synchronized TimeZone getDefaultRef() {
        if (defaultTimeZone == null) {
            defaultTimeZone = NativeTimeZone.getDefaultNativeTimeZone();
        }

        if (defaultTimeZone == null) {
            defaultTimeZone = GMTHolder.INSTANCE;
        }

        return defaultTimeZone;
    }
284835
public Locale getFallbackLocale() {

		Locale locale = null;
		if (this.fallbackToSystemLocale) {
			locale = Locale.getDefault();
		} else {
			locale = new Locale("", "");
		}

		return locale;
	}
1354184
public function getTimeZone() {
        $tzs = $this->user->getPropertyValues(GenerisRdf::PROPERTY_USER_TIMEZONE);
        $tz = empty($tzs) ? '' : (string)current($tzs);
        return empty($tz) ? TIME_ZONE : $tz;
    }
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;
    }
840156
public function getAuthUserDateTimezone()
    {
        $user = $this->getAuthUser();
        if ($user && !empty($user->timezone)) {
            return $user->timezone;
        } else {
            return app_timezone();
        }
    }
1017004
def set_timezone(rollback=False):
    
    if not rollback:
        if contains(filename='/etc/timezone', text=env.TIME_ZONE, use_sudo=True):
            return False
        if env.verbosity:
            print env.host, "CHANGING TIMEZONE /etc/timezone to "+env.TIME_ZONE
        _backup_file('/etc/timezone')
        sudo('echo %s > /tmp/timezone'% env.TIME_ZONE)
        sudo('cp -f /tmp/timezone /etc/timezone')
        sudo('dpkg-reconfigure --frontend noninteractive tzdata')
    else:
        _restore_fie('/etc/timezone')
        sudo('dpkg-reconfigure --frontend noninteractive tzdata')
    return True
337916
public function getTimezoneHourOffset($origin_tz = 'UTC', $format = 'h') {
        $remote_tz = 'UTC';
        if ($origin_tz === 'UTC') {
            return 0 . 'h';
        }
        $origin_dtz = new \DateTimeZone($origin_tz);
        $remote_dtz = new \DateTimeZone($remote_tz);
        $origin_dt = new \DateTime("now", $origin_dtz);
        $remote_dt = new \DateTime("now", $remote_dtz);

        $offset =  $remote_dtz->getOffset($remote_dt) - $origin_dtz->getOffset($origin_dt);
        return $offset / 3600 . $format;
    }
1022021
public static function timezone()
    {
        if (!self::isDebug()) {
            return false;
        }

        $data = date_default_timezone_get();
        return self::i()->dump($data, '! timezone !');
    }
754135
public function getCurrentTimestamp()
    {
        Deprecated::method(3.3);

        $timezone = $this->get('general/timezone');
        $now = date_format(new \DateTime($timezone), 'Y-m-d H:i:s');

        return $now;
    }