Why is the date in datepicker angular showing the last day?

前端 未结 6 694
深忆病人
深忆病人 2021-01-12 13:13

I use datepicker c angular material. Here\'s the code:


 
6条回答
  •  余生分开走
    2021-01-12 13:36

    Similar to the accepted answer, but a little less verbose and will keep the hours/minutes/seconds.

    const dt = new Date(event.value);
    const tz = dt.getTimezoneOffset();
    const seconds = (dt.getTime() / 1000) - (tz * 60);
    

提交回复
热议问题