title: How to get JSON.NET to serialize date/time to ISO 8601?
body: <p>I have a Web API application that returns JSON to consumers who may not be using Microsoft technologies.  When my controller returns an object with DateTime properties as JSON, it serializes the date in this format:</p>
  
  <p><code>2017-03-15T00:00:00-04:00</code></p>
  
  <p>This is giving the consumer a bit of a headache as they're expect it to be in ISO 8601 format.  Some research has told me that JSON.NET now uses ISO 8601 by default (I am using 9.0.1).  When I run this code...</p>
  
  <pre><code>Clipboard.Copy(JsonConvert.SerializeObject(DateTime.Now));
  </code></pre>
  
  <p>...I get this:</p>
  
  <pre><code>2017-03-15T09:10:13.8105498-04:00
  </code></pre>
  
  <p>Wikipedia shows these as valid ISO 8601 formats when expressing full date and time:</p>
  
  <pre><code>2017-03-15T11:45:42+00:00
  2017-03-15T11:45:42Z
  20170315T114542Z
  </code></pre>
  
  <p>However, the output I got above doesn't exactly match any of those.  I want the formatter to use <code>2017-03-15T11:45:42Z</code>.</p>
  
  <p>And probably worthy of another question altogether, adding the below line in my Web API config seems to be ignored as it continues to return JSON in the date originally shown above:</p>
  
  <pre><code>config.Formatters.JsonFormatter.SerializerSettings.Converters.Add(new IsoDateTimeConverter());
  </code></pre>
  
  <p>I assume that once I figure out the core issue, the Web API issue may also be resolved.</p>