获取n天后的日期

getDateAfter_n(days){
let date = new Date();
date.setDate(date.getDate() + days);
let yearStr = date.getFullYear();
let monthStr = ("0"+(date.getMonth()+1)).slice(-2, 8);
let dayStr = ("0"+date.getDate()).slice(-2, 8);
let result = "";
result = yearStr+'-'+monthStr+'-'+dayStr;
return result;
}
posted @ 2017-08-04 17:48  LSunshine  阅读(346)  评论(0编辑  收藏  举报