Returning Moment object instead of Date value in 'YYYY-MM-DD HH:mm:ss' format
I tried the following but getting moment object instead of Date. I searched a lot but none of them give me the solution.
import * as _moment from 'moment';
import { default as _rollupMoment } from 'moment';
const moment = _rollupMoment || _moment;
export const MY_FORMATS = {
parse: {
dateInput: 'YYYY-MM-DD HH:mm:ss',
},
display: {
dateInput: 'YYYY-MM-DD HH:mm:ss',
monthYearLabel: 'MMM YYYY',
dateA11yLabel: 'YYYY-MM-DD HH:mm:ss',
monthYearA11yLabel: 'MMMM YYYY',
},
};
I provided the format inside @Component decorator
@Component({
providers: [
{
provide: DateAdapter,
useClass: MomentDateAdapter,
deps: [MAT_DATE_LOCALE, MAT_MOMENT_DATE_ADAPTER_OPTIONS]
},
{ provide: MAT_DATE_FORMATS, useValue: MY_FORMATS },
]
})
Inside Class =>
dateOfBirth: new FormControl();
try this code.