js 后时间累加

function DateAdd(strInterval, NumDay, dtDate) {
var dtTmp = new Date(dtDate);
if (isNaN(dtTmp)) dtTmp = new Date();
switch (strInterval) {

case "d":
dtTmp = new Date(Date.parse(dtTmp) + (86400000 * parseInt(NumDay)));
break;

}
var mStr = new String(dtTmp.getMonth() + 1);
var dStr = new String(dtTmp.getDate());
if (mStr.length == 1) {
mStr = "0" + mStr;
}
if (dStr.length == 1) {
dStr = "0" + dStr;
}
return dtTmp.getFullYear() + "-" + mStr + "-" + dStr;
}

你可能感兴趣的:(js)