From 904853b12f7e4a5b053e04e3826d4a9a00d1b346 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Sat, 3 Feb 2024 11:53:07 +0530 Subject: [PATCH] fix: use correct datetime format based on current source(datasource) --- packages/nocodb/src/db/BaseModelSqlv2.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/nocodb/src/db/BaseModelSqlv2.ts b/packages/nocodb/src/db/BaseModelSqlv2.ts index ec4fffa3c9..06e3a50e0d 100644 --- a/packages/nocodb/src/db/BaseModelSqlv2.ts +++ b/packages/nocodb/src/db/BaseModelSqlv2.ts @@ -5763,7 +5763,7 @@ class BaseModelSqlv2 { ); if (lastModifiedTimeColumn) { - updateObject[lastModifiedTimeColumn.column_name] = Noco.ncMeta.now(); + updateObject[lastModifiedTimeColumn.column_name] = this.now(); } if (lastModifiedByColumn) { @@ -5798,13 +5798,13 @@ class BaseModelSqlv2 { if (column.system) { if (isInsertData) { if (column.uidt === UITypes.CreatedTime) { - data[column.column_name] = Noco.ncMeta.now(); + data[column.column_name] = this.now(); } else if (column.uidt === UITypes.CreatedBy) { data[column.column_name] = cookie?.user?.id; } } if (column.uidt === UITypes.LastModifiedTime) { - data[column.column_name] = isInsertData ? null : Noco.ncMeta.now(); + data[column.column_name] = isInsertData ? null : this.now(); } else if (column.uidt === UITypes.LastModifiedBy) { data[column.column_name] = isInsertData ? null : cookie?.user?.id; } @@ -5946,6 +5946,12 @@ class BaseModelSqlv2 { } } } + + public now() { + return dayjs() + .utc() + .format(this.isMySQL() ? 'YYYY-MM-DD HH:mm:ss' : 'YYYY-MM-DD HH:mm:ssZ'); + } } export function extractSortsObject(