From 5d2723f4b9d62b8199fd88dd051b6829b09cc62e Mon Sep 17 00:00:00 2001 From: pibica <119127671+pibica@users.noreply.github.com> Date: Thu, 4 May 2023 21:41:11 +0200 Subject: [PATCH] #8546 fix(logging): manage time in seconds or milliseconds (#8547) --- app/docker/helpers/logHelper/formatters.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/docker/helpers/logHelper/formatters.ts b/app/docker/helpers/logHelper/formatters.ts index 54b07bd2c..570e2786e 100644 --- a/app/docker/helpers/logHelper/formatters.ts +++ b/app/docker/helpers/logHelper/formatters.ts @@ -49,7 +49,12 @@ export function formatTime( if (time) { let date = ''; if (typeof time === 'number') { - date = format(new Date(time * 1000), 'Y/MM/dd hh:mmaa'); + // time is a number, so it is the number of seconds OR milliseconds since Unix Epoch (1970-01-01T00:00:00.000Z) + // we need to know if time's unit is second or millisecond + // 253402214400 is the numer of seconds between Unix Epoch and 9999-12-31T00:00:00.000Z + // if time is greater than 253402214400, then time unit cannot be second, so it is millisecond + const timestampInMilliseconds = time > 253402214400 ? time : time * 1000; + date = format(new Date(timestampInMilliseconds), 'Y/MM/dd hh:mmaa'); } else { date = time; }