You are here

function drupal_get_user_timezone in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/includes/bootstrap.inc \drupal_get_user_timezone()

Returns the time zone of the current user.

12 calls to drupal_get_user_timezone()
AccountProxy::setAccount in core/lib/Drupal/Core/Session/AccountProxy.php
Sets the currently wrapped account.
Datelist::processDatelist in core/lib/Drupal/Core/Datetime/Element/Datelist.php
Expands a date element into an array of individual elements.
Datetime::processDatetime in core/lib/Drupal/Core/Datetime/Element/Datetime.php
Expands a datetime element type into date and/or time elements.
DateTimeFieldTest::testDateField in core/modules/datetime/src/Tests/DateTimeFieldTest.php
Tests date field functionality.
DateTimeFieldTest::testDatetimeField in core/modules/datetime/src/Tests/DateTimeFieldTest.php
Tests date and time field.

... See full list

File

core/includes/bootstrap.inc, line 510
Functions that need to be loaded on every Drupal request.

Code

function drupal_get_user_timezone() {
  $user = \Drupal::currentUser();
  $config = \Drupal::config('system.date');
  if ($user && $config
    ->get('timezone.user.configurable') && $user
    ->isAuthenticated() && $user
    ->getTimezone()) {
    return $user
      ->getTimezone();
  }
  else {

    // Ignore PHP strict notice if time zone has not yet been set in the php.ini
    // configuration.
    $config_data_default_timezone = $config
      ->get('timezone.default');
    return !empty($config_data_default_timezone) ? $config_data_default_timezone : @date_default_timezone_get();
  }
}