1 bootstrap.inc backdrop_get_user_timezone()

Returns the time zone of the current user.

File

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

Code

function backdrop_get_user_timezone() {
  global $user;
  $config = config('system.date');

  // If the date config has not yet been set (e.g. upgrading from D7), then use
  // the server default time.
  if ($config->isNew()) {
    return @date_default_timezone_get();
  }
  elseif ($config->get('user_configurable_timezones') && $user->uid && $user->timezone) {
    return $user->timezone;
  }
  else {
    // Ignore PHP strict notice if time zone has not yet been set in the php.ini
    // configuration.
    $config_data_default_timezone = $config->get('default_timezone');
    return !empty($config_data_default_timezone) ? $config_data_default_timezone : @date_default_timezone_get();
  }
}