var myDate = new Date();
var epoch = myDate.getTime(); //1318023197289 number of ms since epoch
var unixEpoch = Math.round(epoch/1000)
- How do you convert
epoch
back to a Date object? - Can you also convert unixEpoch back to a Date object?
var date = new Date(1318023197289);
And, since unixEpoch is simply epoch / 1000, you can similarly multiply the argument in the constructor by 1000.
date
is a number (typeof date == 'number')
but I'm looking to reconstruct a Date Object.
Oct 7, 2011 at 21:52