var myDate = new Date(); var epoch = myDate.getTime(); //1318023197289 number of ms since epoch var unixEpoch = Math.round(epoch/1000)
epoch
var date = new Date(1318023197289);
And, since unixEpoch is simply epoch / 1000, you can similarly multiply the argument in the constructor by 1000.
2.1m questions
2.1m answers
60 comments
57.0k users