You are here

public function TimeZoneResolver::setDefaultTimeZone in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/system/src/TimeZoneResolver.php \Drupal\system\TimeZoneResolver::setDefaultTimeZone()
  2. 9 core/modules/system/src/TimeZoneResolver.php \Drupal\system\TimeZoneResolver::setDefaultTimeZone()

Sets the default time zone.

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);
  }
}