From d15aec9d5890d57fb9ffc1899a93b88fbdd2473a Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Tue, 2 May 2023 13:29:12 +0800 Subject: [PATCH] fix(nocodb): handle timezone with offset in mysql --- 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 82e2224bc6..0921f1698f 100644 --- a/packages/nocodb-nest/src/models/Model.ts +++ b/packages/nocodb-nest/src/models/Model.ts @@ -456,7 +456,15 @@ export default class Model implements TableType { if (base.is_meta) { const d = new Date(val); if (isMySQL) { - val = dayjs(val)?.format('YYYY-MM-DD HH:mm:ss'); + if (val.slice(-1) === 'Z') { + // from UI + val = dayjs(val).format('YYYY-MM-DD HH:mm:ss'); + } else { + val = dayjs + .utc(val) + .utcOffset(d.getTimezoneOffset(), true) + .format('YYYY-MM-DD HH:mm:ss'); + } } else if (isSqlite) { val = dayjs(val).utc().format('YYYY-MM-DD HH:mm:ss'); } else {