public static function HandlerBase::getTimezone

Figure out what timezone we're in; needed for some date manipulations.

1 call to HandlerBase::getTimezone()
HandlerBase::getSQLDateField in drupal/core/modules/views/lib/Drupal/views/Plugin/views/HandlerBase.php
Creates cross-database SQL dates.

File

drupal/core/modules/views/lib/Drupal/views/Plugin/views/HandlerBase.php, line 744
Definition of Drupal\views\Plugin\views\HandlerBase.

Class

HandlerBase

Namespace

Drupal\views\Plugin\views

Code

public static function getTimezone() {
  $timezone = drupal_get_user_timezone();

  // set up the database timezone
  $db_type = Database::getConnection()
    ->databaseType();
  if (in_array($db_type, array(
    'mysql',
    'pgsql',
  ))) {
    $offset = '+00:00';
    static $already_set = FALSE;
    if (!$already_set) {
      if ($db_type == 'pgsql') {
        db_query("SET TIME ZONE INTERVAL '{$offset}' HOUR TO MINUTE");
      }
      elseif ($db_type == 'mysql') {
        db_query("SET @@session.time_zone = '{$offset}'");
      }
      $already_set = TRUE;
    }
  }
  return $timezone;
}