// addDate("5",5,"2004/12/1 00:00:00")
function addDate(type,NumDay,dtDate){
var date = new Date(dtDate)
type = parseInt(type) //类型
lIntval = parseInt(NumDay)//间隔
switch(type){
case 6 ://年
date.setYear(date.getYear() + lIntval)
break;
case 7 ://季度
date.setMonth(date.getMonth() + (lIntval * 3) )
break;
case 5 ://月
date.setMonth(date.getMonth() + lIntval)
break;
case 4 ://天
date.setDate(date.getDate() + lIntval)
break
case 3 ://时
date.setHours(date.getHours() + lIntval)
break
case 2 ://分
date.setMinutes(date.getMinutes() + lIntval)
break
case 1 ://秒
date.setSeconds(date.getSeconds() + lIntval)
break;
default:
}
return date.getYear() +'-' + (date.getMonth()+1) + '-' +date.getDate()+ ' '+ date.getHours()+':'+date.getMinutes()+':'+date.getSeconds()
}
本文地址:http://com.8s8s.com/it/it30699.htm