Click or drag to resize
Json.NETSerialize DateFormatString
 

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

Sample
Usage
 1IList<DateTime> dateList = new List<DateTime>
 2{
 3    new DateTime(2009, 12, 7, 23, 10, 0, DateTimeKind.Utc),
 4    new DateTime(2010, 1, 1, 9, 0, 0, DateTimeKind.Utc),
 5    new DateTime(2010, 2, 10, 10, 0, 0, DateTimeKind.Utc)
 6};
 7
 8string json = JsonConvert.SerializeObject(dateList, new JsonSerializerSettings
 9{
10    DateFormatString = "d MMMM, yyyy",
11    Formatting = Formatting.Indented
12});
13
14Console.WriteLine(json);
15// [
16//   "7 December, 2009",
17//   "1 January, 2010",
18//   "10 February, 2010"
19// ]