I have a knockout/mvc3 application. I am passing the date back to a controller.
controller
public ActionResult PackageUpdate(Package upd
I think the problem lies in how you obtaining those dates to begin with. You show an example using MS date format such as /Date(1357650000000+1100)/
which is not standardized and is slowly being deprecated in favor of ISO8601, which looks like 2013-01-08T13:00:00.000+11:00
.
Indeed, when you JSON.stringify
a javascript Date
object, it uses the ISO8601 format. This also happens with ko.mapping.toJSON
.
There are several solutions to this problem, both client side and server side. This post describes the problem in detail and has some great answers that may help you.
IMHO, the best solution is have your MVC controller emit and consume ISO8601 rather than the old Microsoft date format. The easiest way to do that is by using the Json.Net library which now has ISO8601 as the default so you don't even need to customize it. On the client side, you might also want to look at Moment.js - which makes it easy to parse and format ISO dates.