<script type="text/javascript">
//日期,在原有日期基础上,增加days天数,默认增加1天
function addDate(date, days) {
if(days == undefined || days == ‘‘) {
days = 1;
}
var date = new Date(date);
date.setDate(date.getDate() + days);
var month = date.getMonth() + 1;
var day = date.getDate();
var mm = "‘" + month + "‘";
var dd = "‘" + day + "‘";
//单位数前面加0
if(mm.length == 3) {
month = "0" + month;
}
if(dd.length == 3) {
day = "0" + day;
}
var time = date.getFullYear() + "-" + month + "-" + day
return time;
}
var addTime = addDate("2017-07-24", 2);
console.log(addTime);//2017-07-26
</script>
转自:https://www.cnblogs.com/wush-1215/p/7230397.html