To format the date and time from the date and time picker we need to create a const with the desired date and time format like this:
const CUSTOM_MOMENT_FORMATS: NgxMatDateFormats = {
parse: {
dateInput: "L, LT"
},
display: {
dateInput: "DD/MM/YYYY HH:mm",
monthYearLabel: "MMM YYYY",
dateA11yLabel: "LL",
monthYearA11yLabel: "MMMM YYYY"
}
};
And in the @Component section it needs to be set as provider like this:
providers: [
{ provide: NGX_MAT_DATE_FORMATS, useValue: CUSTOM_MOMENT_FORMATS } // Custom Date Format
]
But how can I set the date and time format dynamically. For example I have set the date and time format in the user settings and want to use this format here.