日期:2014-05-18 浏览次数:20355 次
//获取日期差 function getDate(date, dayspan) { var time = date.valueOf(); time += (dayspan * 24 * 60 * 60 * 1000); return new Date(time); } // w为0为当前周,1为下周 function getWeek(w) { var date = new Date(); var x = date.getDay(); var msg = ""; var weekFirst = getDate(date, w * 7 - x); var weekLast = getDate(date, 6 - x + w * 7); msg = weekFirst.getFullYear() + "-" + eval(weekFirst.getMonth() + 1) + "-" + weekFirst.getDate(); msg += "___" + weekLast.getFullYear() + "-" + eval(weekLast.getMonth() + 1) + "-" + weekLast.getDate(); return msg; } alert(getWeek(0)); alert(getWeek(1));