I need every DateTime object to be in the basic format of "yyyy-MM-dd".
When I was using JSON.Net to do this, it worked fine by adding the following to the WebApiConfig.cs:
config.Formatters.JsonFormatter.SerializerSettings.Converters.Add(
new IsoDateTimeConverter() { DateTimeFormat = "yyyy-MM-dd" });
However, I have reworked my controllers to return IHttpActionResult and just return Json(objectToSerialize). Now the date formats are wrong as I assume that's because this is now using the JavaScriptConverter. Let me know if I'm wrong.
How do I convert every DateTime in my serialized object into the format I need?
By default, they are now showing as "1927-01-29T00:00:00" ... I need "1927-01-29".
I've seen some crazy hacks that seem like total overkill (such as this one).
Is there a clean way to do this?
IHttpActionResultand the return line isreturn Json(myObject).