<script type="text/javascript">
function reDate(a, b, c) {
var date = new Date(a, b - 1, c);
return Math.ceil((c + 7 - (date.getDay() || 7)) / 7);
}
alert(reDate(2007, 3, 4));
</script>

解决方案 »

  1.   

    muxrwc(生命曾可贵,信念价更高,学习要努力,追猫永不弃。) 稍微改一下你的方法:function reDate(a, b, c) 
    {
    var date = new Date(a, b - 1, c);
    var date2 =new Date(a, b - 1, 1);
    return Math.ceil((c+date2.getDay())/7);
    //return Math.ceil((c + 7 - (date.getDay()+1 || 7)) / 7);
    }
    alert(reDate(2007, 4, 29));
      

  2.   

    <SCRIPT LANGUAGE="JavaScript">
    <!--
    Date.prototype.getWeek = function(flag)
    {
      var first = new Date(this.getFullYear(), 0, 1);
      var n = parseInt("1065432".charAt(first.getDay()));
      n = this.getTime()-first.getTime()-n*24*60*60*1000;
      n = Math.ceil(n/(7*24*60*60*1000));
      return (flag==true&&first.getDay()!=1)?(n+1):n;
    };
    alert("今天是今年的第 "+ new Date().getWeek() +" 周\n本年第一周周一在上一年的情况")
    alert("今天是今年的第 "+ new Date().getWeek(true) +" 周")
    alert("2006/10/1 是第 "+ new Date("2006/10/1").getWeek(true) +" 周")
    //-->
    </SCRIPT>
      

  3.   

    更新一下..<script type="text/javascript">
    var getMonthWeek = function (a, b, c) {
    /*
    a = d = 当前日期
    b = 6 - w = 当前周的还有几天过完(不算今天)
    a + b 的和在除以7 就是当天是当前月份的第几周
    */
    var date = new Date(a, parseInt(b) - 1, c), w = date.getDay(), d = date.getDate();
    return Math.ceil(
    (d + 6 - w) / 7
    );
    };var getYearWeek = function (a, b, c) {
    /*
    date1是当前日期
    date2是当年第一天
    d是当前日期是今年第多少天
    用d + 当前年的第一天的周差距的和在除以7就是本年第几周
    */
    var date1 = new Date(a, parseInt(b) - 1, c), date2 = new Date(a, 0, 1),
    d = Math.round((date1.valueOf() - date2.valueOf()) / 86400000);
    return Math.ceil(
    (d + ((date2.getDay() + 1) - 1)) / 7
    );
    };document.write(
    "今天是本月的第 ", getMonthWeek(2007, 10, 17), " 周<br \/>"
    , "今天是本年的第 ", getYearWeek(2007, 10, 17), " 周"
    );
    </script>
      

  4.   

    呵,这个签名..好怀念呢...muxrwc(生命曾可贵,信念价更高,学习要努力,追猫永不弃。)