【学习】取得指定时间范围内的周末日期

function getWeekends(minDate,maxDate)
 {
  var weekends=new Array();
  var no=0;
  var year_1_1;
  var nextyear_1_1;
  
  year_1_1=minDate.substr(0,10).replace(/-/g, '/');
  nextyear_1_1=maxDate.substr(0,10).replace(/-/g, '/');
  var start=new Date(Date.parse(year_1_1));
  var end =new Date(Date.parse(nextyear_1_1));
  var getM,getD;
  while(start<=end)
  {
   var weekx=start.getDay();
   getM=start.getMonth()+1;
   if(getM<10)
   getM="0"+getM;
   
   getD=start.getDate();
   if(getD<10)
   getD="0"+getD;

   if(weekx==0||weekx==6)
   {
    var yea=(start.getYear()<1900)?(start.getYear()+1900):start.getYear();
    weekends[no]=yea+""+getM+""+getD;
         no++;
   }
   start=new Date(start.getTime()+1000*60*60*24);
  }
    alert(weekends.toString());
}

你可能感兴趣的:(Date,function)