You are here

public function date_sql_handler::get_offset in Date 7.3

Same name and namespace in other branches
  1. 5.2 date_api_sql.inc \date_sql_handler::get_offset()
  2. 6.2 date_api_sql.inc \date_sql_handler::get_offset()
  3. 6 date_api_sql.inc \date_sql_handler::get_offset()
  4. 7 date_api/date_api_sql.inc \date_sql_handler::get_offset()
  5. 7.2 date_api/date_api_sql.inc \date_sql_handler::get_offset()

Return timezone offset for the date being processed.

1 call to date_sql_handler::get_offset()
date_sql_handler::sql_tz in date_api/date_api_sql.inc
Select a date value from the database, adjusting for the timezone.

File

date_api/date_api_sql.inc, line 196
SQL helper for Date API.

Class

date_sql_handler
A class to manipulate date SQL.

Code

public 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 = date_now($this->db_timezone);
      }
      $comp_date
        ->setTimezone(timezone_open($this->local_timezone));
      return date_offset_get($comp_date);
    }
  }
  return 0;
}