mirror of https://github.com/portainer/portainer
parent
a062a0bfbe
commit
5d2723f4b9
|
@ -49,7 +49,12 @@ export function formatTime(
|
||||||
if (time) {
|
if (time) {
|
||||||
let date = '';
|
let date = '';
|
||||||
if (typeof time === 'number') {
|
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 {
|
} else {
|
||||||
date = time;
|
date = time;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue