day incorrect in angular material datepicker

后端 未结 15 1874
挽巷
挽巷 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

    If You using Reactive Forms and do this.form.get("dateField").value you must cast it as a Date before submit.

    It'll be something like:

    save() {
      let obj = new MyObj();
      obj.myDate = new Date(this.form.get("mydateField").value);
      this.service.save(obj);
    }
    

提交回复
热议问题