d.setDate(d.getDate()+7) returns 一堆数字

d.setDate(d.getDate()+7) returns a bunch of numbers

当我 运行 下面的代码解析当前日期 + 7 天时,returns 日期变量上的巨大数字;

let d = new Date();
let n = d.setDate(d.getDate()+7);
let m = d.getMonth()+1;
let o = d.getFullYear();
let dateOp = n + "/" + m + "/" + o;

dateOp;

// returns "1609772260625/1/2021"

From the docs, setDate returns 日期和 UNIX 纪元之间的毫秒差。所以,先设置日期,再获取日期:

d.setDate(d.getDate() + 7);
let n = d.getDate();
let m = d.getMonth()+1;
let o = d.getFullYear();
let dateOp = n + "/" + m + "/" + o;

dateOp;