怎么判断当前日期为月末?或者月末的前一天

解决方案 »

  1.   

    得到某月的天数:
    alert((new Date(2007,2,0)).getDate())
      

  2.   

    得到某月的天数:
    alert((new Date(2007,2,0)).getDate())
      

  3.   

    得到某月的天数:
    alert((new Date(2007,2,0)).getDate())
      

  4.   

    http://blog.csdn.net/muxrwc/archive/2007/11/01/1860903.aspx
    可以参考这篇文章
      

  5.   

    http://blog.csdn.net/muxrwc/archive/2007/11/01/1860903.aspx
    可以参考这篇文章
      

  6.   

    <SCRIPT   LANGUAGE= "JavaScript">
    var date = new   Date();
    var year = date.getYear(); //当前年份
    var month = date.getMonth() + 1; //当前月份
    var day = date.getDate(); //当前日
    var lastDay; //最后一天
     if (month == 2)//2月的特殊处理 判断闰年
     {
        if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0)
            {
                lastDay = 29;
            }
    else
            {
                lastDay = 28;
            }
     }
     else if (month == 4 || month == 6 || month == 9 || month == 11)//4 6 9 11月30天
     {
            lastDay = 30;
     }
     else//1 3 5 7 8 10 12月31天
     {
            lastDay = 31;
     }  //判断当日是否为最后一天
     if(lastDay == day)
     {
       alert("今日为月末最后一天");
     }
     else
     {
       alert("今日非月末最后一天");
     }
    </SCRIPT>