var myDate = new Date(); var epoch = myDate.getTime(); //1318023197289 number of ms since epoch var unixEpoch = Math.round(epoch/1000)
var date = new Date(1318023197289);
And, since unixEpoch is simply epoch / 1000, you can similarly multiply the argument in the constructor by 1000.