Files
cfw-autumn/shared/api/common/epochUtils.ts
2026-02-26 09:41:02 +00:00

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}`;
};