function QueryPluginBase::getTimezoneOffset

Same name in other branches
  1. 9 core/modules/views/src/Plugin/views/query/QueryPluginBase.php \Drupal\views\Plugin\views\query\QueryPluginBase::getTimezoneOffset()
  2. 8.9.x core/modules/views/src/Plugin/views/query/QueryPluginBase.php \Drupal\views\Plugin\views\query\QueryPluginBase::getTimezoneOffset()
  3. 11.x core/modules/views/src/Plugin/views/query/QueryPluginBase.php \Drupal\views\Plugin\views\query\QueryPluginBase::getTimezoneOffset()

Get the timezone offset in seconds.

Return value

int The offset, in seconds, for the timezone being used.

1 call to QueryPluginBase::getTimezoneOffset()
Sql::getDateField in core/modules/views/src/Plugin/views/query/Sql.php
Returns a Unix timestamp to database native timestamp expression.

File

core/modules/views/src/Plugin/views/query/QueryPluginBase.php, line 384

Class

QueryPluginBase
Base plugin class for Views queries.

Namespace

Drupal\views\Plugin\views\query

Code

public function getTimezoneOffset() {
    $timezone = $this->setupTimezone();
    $offset = 0;
    if ($timezone) {
        $dtz = new \DateTimeZone($timezone);
        $dt = new \DateTime('now', $dtz);
        $offset = $dtz->getOffset($dt);
    }
    return $offset;
}

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