Browse Source

feat(nocodb): handle db timezone for pg

pull/5642/head
Wing-Kam Wong 1 year ago
parent
commit
7a3091eab2
  1. 6
      packages/nocodb/src/models/Model.ts

6
packages/nocodb/src/models/Model.ts

@ -489,8 +489,12 @@ export default class Model implements TableType {
// e.g. 2022-01-01T10:00:00.000Z -> 2022-01-01 10:00:00
val = dayjs(val).utc().format('YYYY-MM-DD HH:mm:ss');
} else if (isPg) {
// convert to local time
// e.g. 2023-01-01T12:00:00.000Z -> 2023-01-01 20:00:00+08:00
val = dayjs(val).format('YYYY-MM-DD HH:mm:ssZ');
// convert to db timezone
val = knex.raw(`? AT TIME ZONE CURRENT_SETTING('timezone')`, [
dayjs(val).format('YYYY-MM-DD HH:mm:ssZ'),
]);
} else if (isMssql) {
// e.g. 2023-05-10T08:49:32.000Z -> 2023-05-10 08:49:32-08:00
val = dayjs(val).utc().format('YYYY-MM-DD HH:mm:ssZ');

Loading…
Cancel
Save