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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With