I am getting a string value "/Date(1342709595000)/"
in the JSON. I am trying to extract the digits alone and convert the epoch date to meaning ful Javascript Date in the format mm/dd/yy hh:mm:ss . I was able to achieve the first part of the question extracting the digits but couldnot convert it to date object human readable format as available in /
JS Fiddle: /
I am getting a string value "/Date(1342709595000)/"
in the JSON. I am trying to extract the digits alone and convert the epoch date to meaning ful Javascript Date in the format mm/dd/yy hh:mm:ss . I was able to achieve the first part of the question extracting the digits but couldnot convert it to date object human readable format as available in http://www.epochconverter.com/
JS Fiddle: http://jsfiddle.net/meetravi/QzKwE/3/
Share Improve this question asked Jul 19, 2012 at 16:47 RaviRavi 3,2005 gold badges27 silver badges36 bronze badges1 Answer
Reset to default 16There is nothing you really need to do, they are already milliseconds since epoch and javascript dates take milliseconds since epoch.
http://jsfiddle.net/QzKwE/9/
var dateVal ="/Date(1342709595000)/";
var date = new Date(parseFloat(dateVal.substr(6)));
document.write(
(date.getMonth() + 1) + "/" +
date.getDate() + "/" +
date.getFullYear() + " " +
date.getHours() + ":" +
date.getMinutes() + ":" +
date.getSeconds()
);