15 lines
425 B
TypeScript
15 lines
425 B
TypeScript
export function formatDate(inputDate: string | null | undefined): string {
|
|
if (!inputDate) return "";
|
|
|
|
const date = new Date(inputDate);
|
|
|
|
const day = String(date.getDate()).padStart(2, "0");
|
|
|
|
const monthNames = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
|
|
const month = monthNames[date.getMonth()];
|
|
|
|
const year = date.getFullYear();
|
|
|
|
return `${day}-${month}-${year}`;
|
|
}
|