var curr = new Date; // get current datevar first = curr.getDate() - curr.getDay(); // First day is the day of the month - the day of the weekvar last = first + 6; // last day is the first day + 6var firstday = new Date(curr.setDate(first)).toUTCString();var lastday = new Date(curr.setDate(last)).toUTCString();firstday"Sun, 06 Mar 2011 12:25:40 GMT"lastday"Sat, 12 Mar 2011 12:25:40 GMT"
这适用于本周的第一天=本周的星期天,最后一天=本周的星期六。将其延长到周一至周日是微不足道的。
用户可以练习如何在不同月份的第一天和最后一天工作



