You are here

function DateSqlHandler::get_offset in Date 8

Return timezone offset for the date being processed.

1 call to DateSqlHandler::get_offset()
DateSqlHandler::sql_tz in date_api/lib/Drupal/date_api/DateSqlHandler.php
Select a date value from the database, adjusting the value for the timezone.

File

date_api/lib/Drupal/date_api/DateSqlHandler.php, line 106

Class

DateSqlHandler
A class to manipulate date SQL.

Namespace

Drupal\date_api

Code

function get_offset($comp_date = NULL) {
  if (!empty($this->db_timezone) && !empty($this->local_timezone)) {
    if ($this->db_timezone != $this->local_timezone) {
      if (empty($comp_date)) {
        $comp_date = new DrupalDateTime('now', $this->db_timezone);
      }
      $comp_date
        ->setTimezone(timezone_open($this->local_timezone));
      return date_offset_get($comp_date);
    }
  }
  return 0;
}