PDA

View Full Version : how to purse json date



lukesayaw
20 Oct 2010, 1:32 AM
Hi,

I am wondering how to parse a json date time format {"Date":"\/Date(1287602408923)\/"} returned from a web service?

Thanks

merry andrew
20 Oct 2010, 12:06 PM
Here's what I used to parse a string like "\/Date(1287602408923)\/" (passed as oDateStr):


var modDate = function(oDateStr) {
var dateStr = oDateStr.slice(6, 19);
var dateInt = parseInt(dateStr);
dateInt += 86400000; // milliseconds in a day... added to aid accuracy of MS AJAX serialized date
return (new Date(dateInt).format('F j, Y'));
};

lukesayaw
20 Oct 2010, 2:30 PM
thanks a lot for your help!