12 lines
583 B
TypeScript
12 lines
583 B
TypeScript
/** Converts epoch ms to DateTime string format (YYYY-MM-DD HH:MM:SS) */
|
|
export const epochToDateTime = (epochMs: number): string => {
|
|
const date = new Date(epochMs);
|
|
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");
|
|
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
|
|
};
|