应该从哪里下手?

解决方案 »

  1.   

    getDay 
    返回值
    0 星期天 
    1 星期一 
    2 星期二 
    3 星期三 
    4 星期四 
    5 星期五 
    6 星期六 
      

  2.   

    遍历那个月的每一天,用getDay看每天是星期几,然后各种加减乘除计数器就能得到你的答案了
    var myDate = new Date();
    myDate.getYear();        //current year(2位)
    myDate.getFullYear();    //current full year(4位,1970-now)
    myDate.getMonth();       //current month(0-11,0-->1月)
    myDate.getDate();        //current day(1-31)
    myDate.getDay();          //current weekday(0-6,0-->日曜日)
    myDate.getTime();        //current time(Milliseconds form 1970.1.1)
    myDate.getHours();        //current hour(0-23)
    myDate.getMinutes();      //current minute(0-59)
    myDate.getSeconds();      //current second(0-59)
    myDate.getMilliseconds();    //current Milliseconds(0-999)
    myDate.toLocaleDateString();      //get current date
    var mytime=myDate.toLocaleTimeString();     //get current time
    myDate.toLocaleString( );        //get current date and time
      

  3.   

    <%
    Dim a,b
    a=CDate("2009-9-6")b=WeekDayName(Weekday(a))
    response.write b
    %>
      

  4.   

    getDay(); 判断一下1号和下个月1号的数,然后再天数除7
      

  5.   

    var y = 2010, m = 10;alert( "星期数" + Math.ceil((new Date(y, m, 0).getDate() + new Date(y, m - 1, 1).getDay()) / 7) );
    alert( "开始星期" + new Date(y, m - 1, 1).getDay() );
    alert( "结束星期" + new Date(y, m, 0).getDay() );
      

  6.   

    <%
    Dim a
    a=CDate("2010-9-6")response.write Year(a) & "年" & Month(a) & "月,共有" & days(a) & "天<br>"
    response.write Year(a) & "年"&Month(a) & "月,共有" & weeks(a) & "个星期<br>"
    write_fl_Weekday aFunction days(d)
    days=DateDiff("d",a,Dateadd("m",1,d))
    End function
    Function weeks(d)
    ds=days(d)
    If ds Mod 7>0 Then 
    weeks=Int(ds/7)+1
    Else
    weeks=Int(ds/7)
    End if
    End Function
    Function write_fl_Weekday(a)
    f=CDate(Year(a) & "-" & Month(a) & "-1")
    l=DateAdd("d",f,days(a)-1)
    response.write "本月第一天("& f &")是:" & WeekDayName(Weekday(f)) & "<br>"
    response.write "本月最后一天("& l &")是:" & WeekDayName(Weekday(l)) & "<br>"

    End Function 
    %>
      

  7.   

    写了下,供参考:function YearMonth(year, month) {
    this.year = year; 
    this.month = month;

    this.isLeapYear = new Date(year,1,29).getDate() < 29 ? false : true;
    }YearMonth.prototype = {
    days:[31,28,31,30,31,30,31,31,30,31,30,31
    ],
    //该月有几天
    getDaysCount : function() {
    return (this.isLeapYear && this.month==2 ) ? 29 : this.days[this.month-1];
    },
    //该月有几周
    getWeeksCount : function() {
    var firstday = new Date(this.year, this.month, 1).getDay(); 
    var firstWeekDays = 6-firstday;
    var remainDays = this.getDaysCount()-firstWeekDays;

    return Math.ceil(remainDays / 7 + 1); 
    },
    //第一天是周几
    getFirstDayInfo : function() {
    var first = new Date(this.year, this.month, 1);

    return this.getWeek(first.getDay());
    },
    //最后天是周几
    getLastDayInfo : function() {
    var last = (this.isLeapYear && this.month==2 ) ? 29 : this.days[month-1];
    last = new Date(this.year, this.month, last);

    return this.getWeek(first.getDay());
    },
    //判断周几
    getWeek : function(index) {
    switch(index) {
    case 0 : return 'sun'; break;
    case 1 : return 'mon'; break;
    case 2 : return 'tue'; break;
    case 3 : return 'wed'; break;
    case 4 : return 'thu'; break;
    case 5 : return 'fri'; break;
    case 6 : return 'sat'; break;
    default: alert('invalid');
    }
    }
    }window.onload = function() {

    var ym = new YearMonth(2009, 9);
    var days = ym.getDaysCount();
    var weeks = ym.getWeeksCount(); 

    }