Commit aa0105e6 authored by Yuliya Bozhko's avatar Yuliya Bozhko
Browse files

Fix db_format_tsfield() returning value with offset on Postgres 9.2 and later (Bug #1353069)



Change-Id: I827851a16eba74d474234c21dd6b6afc2d06470c
Signed-off-by: default avatarYuliya Bozhko <yuliya.bozhko@totaralms.com>
parent 5210bfb1
......@@ -1439,7 +1439,7 @@ function db_format_timestamp($ts) {
function db_format_tsfield($field, $as = null) {
$tsfield = '';
if (is_postgres()) {
$tsfield = "FLOOR(EXTRACT(EPOCH FROM $field))";
$tsfield = "FLOOR(EXTRACT(EPOCH FROM {$field} AT TIME ZONE CURRENT_SETTING('TIMEZONE')))";
}
else if (is_mysql()) {
$tsfield = "IF($field >= '1970-01-01', UNIX_TIMESTAMP($field), TIMESTAMPDIFF(SECOND, '1970-01-01', $field))";
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment