7 lines
282 B
TypeScript
7 lines
282 B
TypeScript
export function formatDate(date: Date, format: string) {
|
|
return format
|
|
.replaceAll("%Y", date.getFullYear().toString())
|
|
.replaceAll("%M", (date.getMonth() + 1).toString().padStart(2, '0'))
|
|
.replaceAll("%D", date.getDate().toString().padStart(2, '0'));
|
|
}
|