function TimeZoneResolver::setDefaultTimeZone

Same name in other branches
  1. 9 core/modules/system/src/TimeZoneResolver.php \Drupal\system\TimeZoneResolver::setDefaultTimeZone()
  2. 8.9.x core/modules/system/src/TimeZoneResolver.php \Drupal\system\TimeZoneResolver::setDefaultTimeZone()
  3. 11.x core/modules/system/src/TimeZoneResolver.php \Drupal\system\TimeZoneResolver::setDefaultTimeZone()

Sets the default time zone.

1 call to TimeZoneResolver::setDefaultTimeZone()
TimeZoneResolver::onConfigSave in core/modules/system/src/TimeZoneResolver.php
Updates the default time zone when time zone config changes.

File

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

Class

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

Namespace

Drupal\system

Code

public function setDefaultTimeZone() {
    if ($time_zone = $this->getTimeZone()) {
        date_default_timezone_set($time_zone);
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.