Friday, 18 July 2014

Converting timestamp to date



I am trying to convert a timestamp in milliseconds to a new Date.


If I use this code, it returns Fri Aug 09 2013 20:00:00 GMT-0400 (Eastern Daylight Time):



x = 1376092800000;
y = new Date(x);
document.write(y);


But when I change



x = record[i].getElementsByTagName("date_of_consent")[0].childNodes[0].nodeValue;


The document returns "Invalid Date".


I have an XML file with timestamps that I need to convert to date objects. Any suggestions on ways to handle this conversion? Thanks.


No comments:

Post a Comment