Why does Json.NET DeserializeObject change the timezone to local time?

It seems to be ignoring DateParseHandling.DateTimeOffset and is using DateParseHandling.DateTime. I would log an issue here: https://github.com/JamesNK/Newtonsoft.Json


If you're using .NET WebApi you can add the following to the WebApiConfig.cs file to handle this globally in your application.

config.Formatters.JsonFormatter.SerializerSettings.DateTimeZoneHandling = 
    Newtonsoft.Json.DateTimeZoneHandling.Local;

This will specifically tell the JsonFormatter to include and understand the local time zone information when serializing and deserializing a date.


Try using this:

microsoftDateFormatSettings = new JsonSerializerSettings
{
    DateFormatHandling = DateFormatHandling.MicrosoftDateFormat,
    DateTimeZoneHandling = DateTimeZoneHandling.Local
};
var items = JsonConvert.DeserializeObject<List<lstObject>>(jsonString, microsoftDateFormatSettings);

I don't know if it will work in all cases but for me it did. You can try some other values for DateTimeZoneHandling or search for more options on Google.