日期:2014-05-17 浏览次数:20451 次
function writeWeek(strDay){
var d=new Date(strDay);
var n=1000*60*60*24;
var Monday =new Date(d.setTime(d.getTime()-(d.getDay()-1)*n)),
Tuesday = new Date(d.setTime(d.getTime()-(d.getDay()-2)*n)),
Wednesday = new Date(d.setTime(d.getTime()-(d.getDay()-3)*n)),
Thursday =new Date(d.setTime(d.getTime()-(d.getDay()-4)*n)),
Friday = new Date(d.setTime(d.getTime()-(d.getDay()-5)*n)),
Saturday =new Date(d.setTime(d.getTime()-(d.getDay()-6)*n)),
Sunday = new Date(d.setTime(d.getTime()-(d.getDay()-7)*n));
document.write('Monday:'+Monday.toLocaleDateString()+'<br>');
document.write('Tuesday:'+Tuesday.toLocaleDateString()+'<br>');
document.write('Wednesday:'+Wednesday.toLocaleDateString()+'<br>');
document.write('Thursday:'+Thursday.toLocaleDateString()+'<br>');
document.write('Friday:'+Friday.toLocaleDateString()+'<br>');
document.write('Saturday:'+Saturday.toLocaleDateString()+'<br>');
document.write('Sunday:'+Sunday.toLocaleDateString()+'<br><br>');
}
writeWeek('2013-11-14');
writeWeek('2013-11-26');
function formatDate(date) {
return (date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate());
}
var now = new Date();
var nowDayOfWeek = now.getDay();
var nowDay = now.getDate();
var nowMonth = now.getMonth();
var nowYear = now.getFullYear();
for (var i = 1;&n