码迷,mamicode.com
首页 > Web开发 > 详细

JS获得本月的第一天和最后一天

时间:2016-06-11 15:58:34      阅读:158      评论:0      收藏:0      [点我收藏+]

标签:

<script>
 //本月第一天 
 function showFirstDay() 
 { 
     var Nowdate=new Date(); 
     var MonthFirstDay=new Date(Nowdate.getYear(),Nowdate.getMonth(),1).getDate();
      return MonthFirstDay; 
      }
       //本月最后一天 
       function showLastDay() 
       {
            var Nowdate=new Date();
             var tmpDate=new Date(Nowdate.getYear(),Nowdate.getMonth()+1,1); 
             //tmpDate.setDate(tmpDate.getDate() -1); 
             //return new Date(Nowdate.getYear(),Nowdate.getMonth(),tmpDate.getDate()); 
             var MonthLastDay=new Date(tmpDate-86400000).getDate();
            return MonthLastDay;
     } 
     var last = showLastDay(); 
     var start = showFirstDay();
      var date = new Date(); 
      var a = new Array(); 
      for(var i=start;i<=last;i++)
      { 
          a[i-1] = (date.getMonth()+1)+"-"+i;
           } 
</script>

JS获得本月的第一天和最后一天

标签:

原文地址:http://www.cnblogs.com/toSeeMyDream/p/5575368.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!