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
Asked
Active
Viewed 9,141 times
5

georgeawg
- 48,608
- 13
- 72
- 95

Tharindu Senanayake
- 285
- 7
- 22
-
http://plnkr.co/edit/Cz6yY56zVEFj621cndBz?p=info This works – Tharindu Senanayake May 28 '16 at 04:27
-
Then ? what is the issue? – Sajeetharan May 28 '16 at 04:30
-
When I pass the value to the web api even though the date is inserted correctly in the form when the date value is being received by the web api controller that date value is the day before the date entered by the user. That is my problem. For an example if you enter 2012-05-02 then web api will receive 2012-05-01. – Tharindu Senanayake May 28 '16 at 05:38
-
1did you check through fiddler or some tool ? what is the value passed to the service? – Sajeetharan May 28 '16 at 05:40
-
Yes, I used Postman. Then the value comes ok. The issue is when the date value is being passed form angular form to the web api controller. Even when I use console.log the printed date value is correct but it reduces by 1 when passed to web api – Tharindu Senanayake May 28 '16 at 07:22
-
Give me team viewer i can check – Sajeetharan May 28 '16 at 07:25
2 Answers
8
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);
}

Pradeep
- 101
- 1
- 3
2
Just try to use angular-moment as following.
var temp =(moment.utc(local.date));
I wrote a full article about this. FIX IN MD-DATEPICKER TO GET THESELECTED DATE

nextt1
- 3,858
- 2
- 18
- 26