当前时间加上几天

function AddDays(date, days) {
    var nd = new Date(date);
    nd = nd.valueOf();
    nd = nd + days * 24 * 60 * 60 * 1000;
    nd = new Date(nd);
    var y = nd.getFullYear();
    var m = nd.getMonth() + 1;
    var d = nd.getDate();
    if (m <= 9) m = "0" + m;
    if (d <= 9) d = "0" + d;
    var cdate = y + "-" + m + "-" + d;
    console.log(cdate)
    return cdate;
};
AddDays("2020-12-28", 7)

  

posted @ 2021-06-12 18:11  努力~努力再努力~  阅读(45)  评论(0编辑  收藏  举报