js 获取今天后的第N天的具体日期

js 获取今天后的第N天的具体日期

GetDateStr(AddDayCount) {   
    let dd = new Date();  
    dd.setDate(dd.getDate() + AddDayCount);//获取AddDayCount天后的日期  
    let y = dd.getFullYear();   
    let m = (dd.getMonth() + 1) < 10 ? '0' + (dd.getMonth() + 1) : (dd.getMonth() + 1);//获取当前月份的日期,不足10补0  
    let d = dd.getDate() < 10 ? '0' + dd.getDate() : dd.getDate();//获取当前几号,不足10补0  
    return y + "-" + m + "-" + d;   
 }

使用:

this.$utils.GetDateStr(15)

猜你喜欢

转载自blog.csdn.net/yangdl6/article/details/121611925