This is the best solution i found
import {
// modules
NgxMatDatetimePickerModule,
NgxMatDateFormats,
NGX_MAT_DATE_FORMATS,
} from '@angular-material-components/datetime-picker';
import { NgxMatMomentModule, NGX_MAT_MOMENT_DATE_ADAPTER_OPTIONS } from '@angular-material-components/moment-adapter';
export const MOMENT_DATETIME_WITH_SECONDS_FORMAT = 'YYYY-MM-DD HH:mm:ss';
// If using Moment
const CUSTOM_MOMENT_FORMATS: NgxMatDateFormats = {
parse: {
dateInput: MOMENT_DATETIME_WITH_SECONDS_FORMAT,
},
display: {
dateInput: MOMENT_DATETIME_WITH_SECONDS_FORMAT,
monthYearLabel: 'MMM YYYY',
dateA11yLabel: 'LL',
monthYearA11yLabel: 'MMMM YYYY',
},
};
@NgModule({
declarations: [],
imports: [
MatDatepickerModule,
MatMomentDateModule,
NgxMatMomentModule,
NgxMatDatetimePickerModule,
],
exports: [
MatDatepickerModule,
MatMomentDateModule,
NgxMatMomentModule,
NgxMatDatetimePickerModule,
],
providers: [
// values
{ provide: MAT_MOMENT_DATE_ADAPTER_OPTIONS, useValue: { useUtc: true } },
{ provide: NGX_MAT_DATE_FORMATS, useValue: CUSTOM_MOMENT_FORMATS },
{ provide: NGX_MAT_MOMENT_DATE_ADAPTER_OPTIONS, useValue: { useUtc: true } },
],
})
export class AppModule { }