6

I store dates in the database using UTC. The client (javascript) gets the date and converts it into local time. This works fine when running on localhost (meaning web server time zone is same as client time zone). However, when I deploy to Azure, where the web server time zone is UTC, I get back the date already adjusted to the client's time zone, causing the client to show the wrong date time value.

I am assuming that ASP.NET MVC does this conversion. Is that true? If so, how can I prevent it, and force the dates to be passed down unaltered?

I have tried to set the kind of the datetime object being passed down to DateTimeKind.UnSpecified but that does not work.

1
  • Did you ever figure out the answer to this problem? I'm having the same issue.
    – jfielaidof
    May 2, 2017 at 18:07

1 Answer 1

1

If you store the value as UTC and send it down as UTC, the web server's clock doesn't come into play. You need to check your how that date is getting set from the db, if that is good, then check the conversion happening in JavaScript.

Also, if you are doing any .ToString() or using HtmlHelpers, they can also convert on the fly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.