protected function TimeZoneResolver::getTimeZone in Drupal 9
Same name and namespace in other branches
- 8 core/modules/system/src/TimeZoneResolver.php \Drupal\system\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\systemCode
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;
}