From 7e51d3fbe7671db5ba9e62b2336b91ab9fd63f3b Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Tue, 2 May 2023 13:49:24 +0800 Subject: [PATCH] fix(nocodb): handle timezone with offset in sqlite --- packages/nocodb-nest/src/models/Model.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/nocodb-nest/src/models/Model.ts b/packages/nocodb-nest/src/models/Model.ts index 0921f1698f..ca5013c9d7 100644 --- a/packages/nocodb-nest/src/models/Model.ts +++ b/packages/nocodb-nest/src/models/Model.ts @@ -466,7 +466,15 @@ export default class Model implements TableType { .format('YYYY-MM-DD HH:mm:ss'); } } else if (isSqlite) { - val = dayjs(val).utc().format('YYYY-MM-DD HH:mm:ss'); + let keepLocalTime = false; + if (val.slice(-1) === 'Z') { + // from UI + keepLocalTime = true; + } + val = dayjs + .utc(val) + .utcOffset(d.getTimezoneOffset(), keepLocalTime) + .format('YYYY-MM-DD HH:mm:ss'); } else { let keepLocalTime = false; if (val.slice(-1) === 'Z') {