跳到主要内容

转化时间戳

通过 Date.now() 转化

const timestamp = Date.now();
console.log(timestamp);

通过 Date.parse() 转化

const date = new Date();
const timestamp = Date.parse(date);
console.log(timestamp);

通过 new Date().valueOf() 转化

const timestamp = new Date().valueOf();
console.log(timestamp);

通过 new Date().getTime() 转化

const timestamp = new Date().getTime();
console.log(timestamp);