var oDate = new Date();
oDate.getTime(); // 当前日期的毫秒数,想在这个基础上得到加一年的毫秒数,表达式要怎么写呢?
var oDate = new Date();
oDate.getTime(); // 当前日期的毫秒数,想在这个基础上得到加一年的毫秒数,表达式要怎么写呢?
你算一下一整年有多少毫秒不就得了……
365(天)* 24(小时) * 60(分钟) * 60(秒)* 1000 (毫秒) = 31536000000
const now = new Date();
const next = new Date(now.getTime() + 31536000000);
console.log(now.toDateString()); //Wed Feb 22 2017
console.log(next.toDateString()); //Thu Feb 22 2018
13 回答12.9k 阅读
7 回答2.1k 阅读
3 回答1.3k 阅读✓ 已解决
2 回答1.3k 阅读✓ 已解决
6 回答1.2k 阅读✓ 已解决
6 回答1.1k 阅读
2 回答1.3k 阅读✓ 已解决
一年的毫秒不就等于
还有一种方法: