Angular Material Datepicker返回确切日期的前一天 [英] Angular Material Datepicker returns one day before the exact date
问题描述
我在网站上使用角形材料,当我将日期发送到Web api时,它显示在所选日期的前一天。例如,如果我输入2016-01-03,则它将发送2016-01-02。我该如何解决此问题。我没有更改任何形式的代码,这些代码的格式如下:
https://material.angularjs.org/latest/demo/datepicker
我们最近遇到了同样的问题,如
> https://github.com/angular-ui/ui-date/issues/88
工作正常。希望对某些人有所帮助。
函数AdjustDateForTimeOffset(dateToAdjust){
var offsetMs = dateToAdjust.getTimezoneOffset()* 60000;
返回新的Date(dateToAdjust.getTime()-offsetMs);
}
Im using angular material in my web site and when I send the date to my web api, it shows on day before the selected date. For an example if I put in 2016-01-03 then it will send 2016-01-02. How can I fix this issue. I haven't change any code form the original code provided in angular material web site the link to the code is below
https://material.angularjs.org/latest/demo/datepicker
we recently faced the same , adjusting the value before posting like said in https://github.com/angular-ui/ui-date/issues/88
works fine. Hope its helpfull for some one.
function adjustDateForTimeOffset(dateToAdjust) {
var offsetMs = dateToAdjust.getTimezoneOffset() * 60000;
return new Date(dateToAdjust.getTime() - offsetMs);
}
这篇关于Angular Material Datepicker返回确切日期的前一天的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!