function getWeek (year,month,week){
var time = new Date(year + '-'+ month);
var firstweek = time.getDay();
var firsttime = time.getTime();
var onedata = 24*3600*1000;
var lastweekTime =new Date(firsttime + (7-firstweek+1)*onedata + (week-1)*7*onedata);
var months = lastweekTime.getMonth() + 1;
var day = lastweekTime.getDate();
var monthday;
if(month != 12){
monthday = ( new Date(new Date(year + '-'+ (month+1) + '-' + 1) - onedata).getDate());
}else{
monthday = ( new Date(new Date((year+1) + '-'+ 1 + '-' + 1) - onedata).getDate());
}
if(months != month){
months = month;
day = monthday;
}
if(week > 1){
var firstweek ;
if( new Date(year + '-' + months+'-'+day).getDay() == 1){
firstweek = months +'月'+(parseInt(day) - 7) + '日';
}else{
firstweek = months +'月'+(parseInt(day) - ( new Date(year + '-' + months+'-'+day).getDay()-1)) + '日';
}
}else{
var firstweek = months +'月'+ 1 + '日';
}
var lastweek = months + '月'+ day + '日';
return ((year + '年' + firstweek) + '-' +(year + '年' + lastweek));
}
帮朋友封装一个函数,时间急,写的有点乱,但意思到位了。