1

Hello I have a problem with different date formats between angularjs app and ASP.NET. I have this code in js:

$http.post("server/api/save", {date: new Date(2018, 1, 5)}) 
in date is: Fri Jan 05 2018 00:00:00 GMT+0100

But in server is this: 04.01.2018 23:00:00. In ASP.NET is datatype of date Nullable<System.DateTime>. where would be the problem that the yesterday's date will come to my server?

Thanks

1 Answer 1

1

It could be because of day light saving;

var date = new Date(2018, 1, 5);
if (date.getTimezoneOffset() == -120) {
    date.setHours(date.getHours() + 1);
}
$http.post("server/api/save", {date: date}) 
Sign up to request clarification or add additional context in comments.

3 Comments

Thanks for answer, but this doestn work. In server is 4.1 again.
can be an error in date.setHours(date.getHours() + 1);, Sould I change the day?
No, I put that condition provide example "date.getTimezoneOffset() == -120". You should consider your current time between utc time difference.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.