<script language=javascript>
Date.prototype.toDateString=function(){
var strMonth=(this.getMonth()+parseInt(1)).toString()
var strDate=this.getDate().toString()
return this.getFullYear()+"-"+((strMonth.length==1)?("0"+strMonth):(strMonth))+"-"+((strDate.length==1)?("0"+strDate):(strDate));
}
var str="2007-01-01"
var temp=new Date(Date.parse(str.replace(/-/g,"\/")))
var temp2=new Date(temp.getFullYear()+parseInt(3),temp.getMonth(),temp.getDate()-1)
alert(temp2.toDateString())
</script>
Date.prototype.toDateString=function(){
var strMonth=(this.getMonth()+parseInt(1)).toString()
var strDate=this.getDate().toString()
return this.getFullYear()+"-"+((strMonth.length==1)?("0"+strMonth):(strMonth))+"-"+((strDate.length==1)?("0"+strDate):(strDate));
}
var str="2007-01-01"
var temp=new Date(Date.parse(str.replace(/-/g,"\/")))
var temp2=new Date(temp.getFullYear()+parseInt(3),temp.getMonth(),temp.getDate()-1)
alert(temp2.toDateString())
</script>
var d2=new Date();
d2.setTime(d1.getTime()+(365*3)*24*60*60*1000);//注意:此中的365为一年的天数,如为闰年请再多加一
//因2008为闰年,所以365*3正好是三年减一天
//分别显示两个日期的年月日
alert("D1: "+d1.getYear()+" "+d1.getMonth()+" "+d1.getDate());
alert("D2 "+d2.getYear()+" "+d2.getMonth()+" "+d2.getDate());