JS获取任意时间的时间戳 使用场景: 需要获取1小时后的时间戳,用来做获取到优惠券之后的有效期的倒计时提醒功能等。 话不多说直接上代码 let a = new Date().getTime() console.log('当前时间戳', a) let b = a + 60 * 60 * 1000 let c = new Date(b) let d = new Date() console.log('当前时间', d) console.log('1H后时间', c)