I am having issues in my local environment (ASP.NET MVC - UTC-5 Offset) where MVC Model Binding is converting my UTC DateTimes back to the Local DateTime.
In the DB we are attempting to store all datetimes in UTC. EF Reads these dates fine out of the DB correctly as UTC, and on the client i am succesffuly converting these back to local time on display, and sending UTC back to the server on posts. Here is an example post:
However on entry into the controller, the datetime is now in local time:
My JsonSerializer in global.asax looks like this:
JsonConvert.DefaultSettings = () => new JsonSerializerSettings
{
DateTimeZoneHandling = DateTimeZoneHandling.Utc
};
I assumed the Json serialiser would convert that to UTC on model binding back in to the controller, but its not. Other than manually converting every date on back to UTC, is there any way to get this working site wide so that it reads the JSON dates from clients as UTC?