0%

JS 获取时间戳

问题

JS 获取时间戳

解决

方法一:(只精确到秒,把毫秒改成 000 显示)

1
const timestamp = Date.parse(new Date());

方法二:(精确到毫秒)

1
const timestamp = new Date().valueOf();

方法三:(精确到毫秒)

1
const timestamp = new Date().getTime();