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;
}

posted @ 2013-02-18 11:28  历史的驱动  阅读(478)  评论(0编辑  收藏  举报