Auto convert dates on the client side (if you use jQuery)
--
You didn't specify it, but since you're using ASP.NET MVC you could be using jQuery. If you do, converting to actual dates just became simpler if you use code provided on this blog post. The code extends jQuery's $.parseJSON()
functionality, so it automatically converts ISO and ASP.NET date strings to actual JavaScript dates.
I use it with ASP.NET MVC, and it works like a charm. The best part is that it's also backwards compatible. Existing code that uses $.parseJSON()
will work just like before (and actually work the same), but if you provide the second parameter and set its value to true
, all dates will get automatically converted for you.
The extension uses native browser JSON support where applicable and also works in others that don't. Modern browsers support this functionality anyway.