Geeks With Blogs
Łukasz Kuryło's blog

I have today a little problem to parse in js a DateTime object, which I serialized to json in the acion method on the server by

return Json(messages);

In javascript, the date looks that: /Date(1309936900864)/

 

To parse the date in js I have used:

var parsedDate = new Date(parseInt(messages[i].CreatedDate.replace("/Date(", "").replace(")/",""), 10));

 

Posted on Wednesday, July 6, 2011 9:49 AM JavaScript | Back to top


Comments on this post: Getting in js DateTime object serialized to json on the server

# re: Getting in js DateTime object serialized to json on the server
Requesting Gravatar...
I typically format the date on the server (fewer time zone issues), but you can also eval the date client side.

var parsedDate = eval(messages[i].CreatedDate.replace("/",""))
Left by Ryan on Jul 09, 2011 1:19 AM

Comments have been closed on this topic.
Copyright © Łukasz Kuryło | Powered by: GeeksWithBlogs.net