Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. TimeZoneResolver.php

function TimeZoneResolver::getTimeZone

Gets the time zone based on site and user configuration.

Return value

string|null The time zone, or NULL if nothing is set.

1 call to TimeZoneResolver::getTimeZone()
TimeZoneResolver::setDefaultTimeZone in core/modules/system/src/TimeZoneResolver.php
Sets the default time zone.

File

core/modules/system/src/TimeZoneResolver.php, line 89

Class

TimeZoneResolver
Event handler that resolves time zone based on site and user configuration.

Namespace

Drupal\system

Code

protected function getTimeZone() {
    $config = $this->configFactory
        ->get('system.date');
    if ($config->get('timezone.user.configurable') && $this->currentUser
        ->isAuthenticated() && $this->currentUser
        ->getTimezone()) {
        return $this->currentUser
            ->getTimeZone();
    }
    elseif ($default_timezone = $config->get('timezone.default')) {
        return $default_timezone;
    }
    return NULL;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal