Commit 936f43a4 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Workaround for mysql's UNIX_TIMESTAMP() function not returning negative timestamps (bug 3255)

parent 4a90d662
......@@ -1406,7 +1406,7 @@ function db_format_tsfield($field, $as = null) {
$tsfield = "FLOOR(EXTRACT(EPOCH FROM $field))";
}
else if (is_mysql()) {
$tsfield = "UNIX_TIMESTAMP($field)";
$tsfield = "IF($field >= '1970-01-01', UNIX_TIMESTAMP($field), TIMESTAMPDIFF(SECOND, '1970-01-01', $field))";
}
else {
throw new SQLException('db_format_tsfield() is not implemented for your database engine (' . get_config('dbtype') . ')');
......
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