js获取时间戳

1.Date.parse(new Date())
const timestamp = Date.parse(new Date());
console.log(timestamp);
//输出 1591669256000   13位

2.Math.round(new Date())
const timestamp = Math.round(new Date());
console.log(timestamp);  
//输出 1591669961203   13位

3.(new Date()).valueOf()
const timestamp = (new Date()).valueOf();
console.log(timestamp);
//输出 1591670037603   13位

4.new Date().getTime()
const timestamp = new Date().getTime();
console.log(timestamp);
//输出 1591670068833   13位

5.+new Date()
const timestamp = +new Date();
console.log(timestamp);
//输出 1591670099066   13位

你可能感兴趣的:(javascript,前端,前端,javascript)