Saturday, 31 August 2013

Date to epoch and vice versa - JavaScript

Date to epoch and vice versa - JavaScript

I need to convert date to Java epoch and then read it and convert back.
Not sure what I'm doing wrong here?
var date = new Date('1/3/2013');
var timeStamp = date.getTime();
console.log(timeStamp);
var revertDate = new Date(timeStamp);
console.log(revertDate.getDate()+'/'+revertDate.getMonth()+'/'+revertDate.getFullYear());
The out put is 3/0/2013 instad 1/3/2013?
fiddle link

No comments:

Post a Comment