JavaScript获取时间戳(三种方式)

2018-08-13 10:49

JavaScript获取时间戳(三种方式)


-----------(方法一-----------

var timestamp = (new Date()).getTime();
console.log(timestamp); //1495302061441


-----------(方法二-----------
var timestamp2 = (new Date()).valueOf();
console.log(timestamp2); //1495302061447


-----------(方法三-----------
var timestamp3 = Date.parse(new Date());
console.log(timestamp3);//1495302061000

相关推荐