fix(timezone): use UTC for database storage and local time for UI display
Backend changes: - SQL Server dialect: GETDATE() → SYSUTCDATETIME() - MySQL dialect: NOW() → UTC_TIMESTAMP() - Ensures OperationTime and EndTime use consistent UTC timezone Frontend changes: - formatDateTime: display UTC timestamps in user's local timezone - Uses getFullYear/getMonth/getDate/getHours (local) instead of UTC methods Data migration: - Executed migration script to fix historical OperationTime records - All existing records now have correct UTC timestamps - Execution duration now accurate (minutes, not hours) Impact: - New executions store UTC timestamps correctly - UI displays times in user's local timezone (UTC+8 for CN users) - Historical data corrected via migration - Time difference between OperationTime and EndTime now accurate
This commit is contained in:
@@ -88,12 +88,13 @@ const formatDateTime = (dateStr: string | Date | null | undefined): string => {
|
||||
return String(dateStr)
|
||||
}
|
||||
|
||||
const year = date.getUTCFullYear()
|
||||
const month = String(date.getUTCMonth() + 1).padStart(2, '0')
|
||||
const day = String(date.getUTCDate()).padStart(2, '0')
|
||||
const hours = String(date.getUTCHours()).padStart(2, '0')
|
||||
const minutes = String(date.getUTCMinutes()).padStart(2, '0')
|
||||
const seconds = String(date.getUTCSeconds()).padStart(2, '0')
|
||||
// Use local time instead of UTC for display
|
||||
const year = date.getFullYear()
|
||||
const month = String(date.getMonth() + 1).padStart(2, '0')
|
||||
const day = String(date.getDate()).padStart(2, '0')
|
||||
const hours = String(date.getHours()).padStart(2, '0')
|
||||
const minutes = String(date.getMinutes()).padStart(2, '0')
|
||||
const seconds = String(date.getSeconds()).padStart(2, '0')
|
||||
|
||||
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user