Click or drag to resize
Json.NETDateFormatHandling setting
 

This sample uses the DateFormatHandling setting to control how DateTime and DateTimeOffset are serialized.

Sample
Usage
 1DateTime mayanEndOfTheWorld = new DateTime(2012, 12, 21);
 2
 3string jsonIsoDate = JsonConvert.SerializeObject(mayanEndOfTheWorld);
 4
 5Console.WriteLine(jsonIsoDate);
 6// "2012-12-21T00:00:00"
 7
 8string jsonMsDate = JsonConvert.SerializeObject(mayanEndOfTheWorld, new JsonSerializerSettings
 9{
10    DateFormatHandling = DateFormatHandling.MicrosoftDateFormat
11});
12
13Console.WriteLine(jsonMsDate);
14// "\/Date(1356044400000+0100)\/"