function date_sql_handler::sql_offset in Date 6
Same name and namespace in other branches
- 5.2 date_api_sql.inc \date_sql_handler::sql_offset()
- 6.2 date_api_sql.inc \date_sql_handler::sql_offset()
- 7.3 date_api/date_api_sql.inc \date_sql_handler::sql_offset()
- 7 date_api/date_api_sql.inc \date_sql_handler::sql_offset()
- 7.2 date_api/date_api_sql.inc \date_sql_handler::sql_offset()
Adjust a field value by an offset in seconds.
1 call to date_sql_handler::sql_offset()
- date_sql_handler::sql_tz in ./
date_api_sql.inc - Select a date value from the database, adjusting the value for the timezone.
File
- ./
date_api_sql.inc, line 185
Class
- date_sql_handler
- A class to manipulate date SQL.
Code
function sql_offset($field, $offset = NULL) {
if (!empty($offset)) {
switch ($this->db_type) {
case 'mysql':
case 'mysqli':
return "ADDTIME({$field}, SEC_TO_TIME({$offset}))";
case 'pgsql':
return "({$field} + 'INTERVAL {$offset} SECONDS')";
}
}
return $field;
}