drupal_get_user_timezone

drupal_get_user_timezone()

Returns the time zone of the current user.

File

core/includes/bootstrap.inc, line 516
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();
  }
}
doc_Drupal
2016-10-29 09:03:15
Comments
Leave a Comment

Please login to continue.