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.