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

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

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


 
6条回答
  •  孤街浪徒
    2021-01-12 13:25

    You may resolve it like this : For example, if your are getting date in -> one_day_back_date_value

    var one_day_back_date_value = moment.tz(moment(date_value_from_backend), 0).format("YYYY-MM-DD");
    date_value_from_backend = moment(one_day_back_date_value).toDate();
    

    Please note : moment and moment-timezone libraries are must for this. Include moment library above the moment-timezone library.

提交回复
热议问题