This project has moved. For the latest updates, please go here.


IsoDateTimeConverter doesn't properly serialize milliseconds


I'm seeing the IsoDateTimeConverter serialize DateTimes in strings such as this:
Various sources on the internet (I can't find the actual ISO8601 spec, strangely) specify that the milliseconds portion must be 3 digits, not two. And, in fact if you use Internet Explorer's built-in Date.parse function, it will fail on the above format, but succeeds with the trailing zero.
So, I think the IsoDateTimeConverter should be modified to include 3 digits of precision to match the spec (and avoid headaches with people trying to use DateTimes returned to the browser via a JSON-based API).
Closed Jul 25, 2012 at 5:30 AM by JamesNK
IsoDateTimeConverter is mostly there for backwards comparability but if you need to change DateTimeFormat.


pmoriarity wrote Jun 15, 2012 at 9:27 PM

This worked for me until they fix it.
        var formatter = GlobalConfiguration.Configuration.Formatters.JsonFormatter;

        IsoDateTimeConverter iso = new IsoDateTimeConverter();
        iso.DateTimeFormat = "yyyy'-'MM'-'dd'T'HH':'mm':'ss.fffK";

        if (formatter != null) 
            formatter.SerializerSettings = new JsonSerializerSettings() 
                Converters = new JsonConverter[] { iso }        

wrote Jul 25, 2012 at 5:30 AM

robcube wrote Jan 9, 2013 at 9:43 PM

to me, this is still broken even with the latest Json.NET converter. The above fix by pmoriarity cinched it!

wrote Feb 22, 2013 at 1:48 AM

wrote May 16, 2013 at 12:37 PM