bun_http_template/src/helpers/char.ts
2024-12-21 19:24:48 -05:00

6 lines
271 B
TypeScript

export function timestampToReadable(timestamp?: number): string {
const date: Date =
timestamp && !isNaN(timestamp) ? new Date(timestamp) : new Date();
if (isNaN(date.getTime())) return "Invalid Date";
return date.toISOString().replace("T", " ").replace("Z", "");
}