12 lines
572 B
TypeScript
12 lines
572 B
TypeScript
/** Converts epoch ms to ClickHouse DateTime string format */
|
|
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}`;
|
|
};
|