I recently started working with KnockoutJs and quickly realized using the default Json(myModelWithADate) resulted in the default json encoding of \\/Date(
I loved Andres Toro's answer except that in my case, input fields are expecting formatted strings. So I am using JQuery to format my dates according to my favorite format provided by my helper @Html.ConvertDateFormat()
Hope this helps someone day.
var mapping = {
'ActualDateTime': {
update: function (options) {
var d = /\/Date\((\d*)\)\//.exec(options.data);
return (d) ? $.datepicker.formatDate('@Html.ConvertDateFormat()', new Date(+d[1])) : value;
//return "5/10/2017";
}
}
};
var paymentModel = ko.mapping.fromJS(modelJSON, mapping);