var d = new Date();
var newd = d + 24*60*60*7;
alert(newd.getDate());

解决方案 »

  1.   

    <script>
    var msize = new Array(2,1,0,1,0,1,0,1,1,0,1,0,1);
    function MyDate(ayear,amonth,adate)
    {
    this.year = ayear;
    this.month = amonth;
    this.date = adate;
    this.nextday = DoGoNextDay_MyDate;
    this.prevday = DoGoPrevDay_MyDate;
    this.getdate = DoGetDate_MyDate;
    }
    function DoGetDate_MyDate(){ return (this.year + "年" + this.month + "月" + this.date + "日")}
    function DoGoNextDay_MyDate()
    {
    this.date ++;
    maxmonth = (msize[this.month]==1)?31:30;
    maxmonth = (this.month==2)?((this.year%4==0)?29:28):maxmonth;
    if(this.date>maxmonth)
    {
    this.month++;
    this.date = 1;
    if(this.month>12)
    {
    this.year++;
    this.month = 1;
    this.date = 1;
    }
    }
    }
    function DoGoPrevDay_MyDate()
    {
    this.date --;
    if(this.date==0)
    {
    this.month--;
    if(this.month)
    {
    if(msize[this.month]) this.date = 31;
    else
    {
    this.date = 30;
    if(this.month == 2) this.date = 28;
    if(this.year%4==0) this.date = 29;
    }
    }
    else
    {
    this.year--;
    this.month = 12;
    this.date = 12;
    }
    }

    }
    </script><script>
    function add(myday)
    {
    today= new Date();
    abc = new MyDate(today.getFullYear(),today.getMonth()+1,today.getDate());
    for(n=0;n<myday;n++)
    abc.nextday();
    document.all.newday.value=abc.getdate();
    }
    </script>
    <input type=text name=afterday onblur=add(this.value)>日后是<input type=text name=newday readOnly>