While browsing the web, I stumbled upon this JavaScript file on GitHub created by marlun78.
I decided to contribute to the TypeScript community by sharing my rewritten version of the code here. Take a look:
export interface IFormatDateSettings {
days?: string[];
... (Code continues with various formatting settings and patterns)
}
...
// Format Date Service Class containing various date formatting methods
Feel free to utilize it as follows:
let date: Date = new Date();
let formatDateService = new FormatDateService();
let formattedDate1: string = formatDateService.formatDate(date, 'dd MM yy');
let formattedDate2: string = formatDateService.formatDate(date, 'yyyy/MM');
let formattedDate3: string = formatDateService.formatDate(date, 'MMMM d, yyyy');