js获取时间戳的三种方式

时间:2021-03-01 12:22:56
 

js获取时间戳的三种方式

CreateTime--2018年5月23日08:44:10

Author:Marydon

// 方式一:推荐使用
var timestamp=new Date().getTime();
console.log(timestamp);
// 方式二
timestamp = (new Date()).valueOf();
console.log(timestamp);
// 方式三
timestamp = Date.parse(new Date());
console.log(timestamp);

效果展示

js获取时间戳的三种方式