day incorrect in angular material datepicker

后端 未结 15 1854
挽巷
挽巷 2020-12-08 11:01

When I select a date I see the correct date in the field but, when I save, the datepicker send the day before the date I have selected ( 3 hours offset ) i am using angular

15条回答
  •  北海茫月
    2020-12-08 11:23

    https://github.com/angular/material2/issues/7167#issuecomment-402061126

    You can change the default behaviour to parse dates as UTC by providing the MAT_MOMENT_DATA_ADAPTER_OPTIONS and setting it to useUtc: true.

    @NgModule({ 
        imports: [MatDatepickerModule, MatMomentDateModule], 
        providers: [ 
            { provide: MAT_MOMENT_DATE_ADAPTER_OPTIONS, useValue: { useUtc: true } } 
        ] 
    })
    

提交回复
热议问题