I am migrating a web API from .NET Core 2.2 to 3.0 and want to use the new System.Text.Json
. When using Newtonsoft
I was able to format DateTime
using the code below. How can I accomplish the same?
.AddJsonOptions(options =>
{
options.SerializerSettings.DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc;
options.SerializerSettings.DateFormatString = "yyyy'-'MM'-'dd'T'HH':'mm':'ssZ";
});
Z
is appended to the string. A local time will include the local timezone offset – Panagiotis Kanavos