I am sending date values from C# application via JSON but instead of a standard date, it appears in this format /Date(1324512000000)/
Can anyone please tell me how to send it from C# in the format it expects? Thanks
I am sending date values from C# application via JSON but instead of a standard date, it appears in this format /Date(1324512000000)/
Can anyone please tell me how to send it from C# in the format it expects? Thanks
That's how the JavaScriptSerializer is handling dates:
Date object, represented in JSON as "/Date(number of ticks)/". The number of ticks is a positive or negative long value that indicates the number of ticks (milliseconds) that have elapsed since midnight 01 January, 1970 UTC.
You could convert this into a javascript Date like this:
var date = new Date(parseInt(jsonDate.substr(6)));
JSON doesn't recognize c#'s datetime object. You should send it back as a string by calling .toString on your datetime variable in your controller.
That's just how dates are expressed in JSON. See here for how to parse it back into something useful in javascript: How do I format a Microsoft JSON date?