day incorrect in angular material datepicker

后端 未结 15 1877
挽巷
挽巷 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:27

    This worked for me:

    const date = new Date(dateFromDatepicker);
    date.toLocaleString();   // displays the correct date that was chosen in the datepicker
    

    I'm using reactive forms. dateFromDatepicker is the value I got from the Angular material datepicker formControl.

    Source: https://github.com/angular-ui/ui-date/issues/88

提交回复
热议问题