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? - 如何将epoch转换回Date对象?
- Can you also convert unixEpoch back to a Date object?
- 你还可以将unixEpoch转换回Date对象吗?
1 个解决方案
#1
79
var date = new Date(1318023197289);
And, since unixEpoch is simply epoch / 1000, you can similarly multiply the argument in the constructor by 1000.
并且,由于unixEpoch只是epoch / 1000,因此您可以将构造函数中的参数乘以1000。
#1
79
var date = new Date(1318023197289);
And, since unixEpoch is simply epoch / 1000, you can similarly multiply the argument in the constructor by 1000.
并且,由于unixEpoch只是epoch / 1000,因此您可以将构造函数中的参数乘以1000。