function DrupalDateTime::prepareTimezone

Same name in other branches
  1. 9 core/lib/Drupal/Core/Datetime/DrupalDateTime.php \Drupal\Core\Datetime\DrupalDateTime::prepareTimezone()
  2. 8.9.x core/lib/Drupal/Core/Datetime/DrupalDateTime.php \Drupal\Core\Datetime\DrupalDateTime::prepareTimezone()
  3. 11.x core/lib/Drupal/Core/Datetime/DrupalDateTime.php \Drupal\Core\Datetime\DrupalDateTime::prepareTimezone()

Overrides prepareTimezone().

Override basic component timezone handling to use Drupal's knowledge of the preferred user timezone.

Overrides DateTimePlus::prepareTimezone

File

core/lib/Drupal/Core/Datetime/DrupalDateTime.php, line 102

Class

DrupalDateTime
Extends DateTimePlus().

Namespace

Drupal\Core\Datetime

Code

protected function prepareTimezone($timezone) {
    if (empty($timezone)) {
        // Fallback to user or system default timezone.
        $timezone = date_default_timezone_get();
    }
    return parent::prepareTimezone($timezone);
}

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