I have a object that I serialize with the JavaScriptSerializer and output it in a javascript variable.
A property on this object is a date which gets converted to eg. "/Date(1309498021672)/"
I then send this value to the server via a ui wcf service call. I want to deserialize this value in to a DateTime object.
How can I do this? I am working with asp.net c# web application.
Your string format is just a little off, but this will deserialize to a proper date.
var serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
string json = "\"\\/Date(1309498021672)\\/\"";
DateTime date = serializer.Deserialize<DateTime>(json);
// date is 7/1/2011 5:27:01 AM
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With