js日期天数相加

function addDate(dateStr,diffDay){
  var dateTime = (new Date(dateStr)).getTime();
  var diffTimeLong = dateTime + (diffDay)*24*3600*1000;
  var diffTime = new Date(diffTimeLong);
  var m = (diffTime.getMonth()+1)<10?"0"+(diffTime.getMonth()+1):(diffTime.getMonth()+1);
  var d = diffTime.getDate()<10?"0"+diffTime.getDate():diffTime.getDate();
  return diffTime.getFullYear()+"-"+m +"-"+d;
 }

 

你可能感兴趣的:(日期相加)