You are here

public function QueryPluginBase::getTimezoneOffset in Drupal 9

Same name and namespace in other branches
  1. 8 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 374

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;
}