js获取当前所在周一时间,并计算其前、后N天日期

var now = new Date();
var date = new Date(now-(now.getDay()-1)*86400000); //当前所在周周一的日期
var myDate = new Date(date);                        //格式化当前得到的日期
var month = myDate.getMonth()+1;     //得到当前所在周周一的月份,下面依次类推
var day = myDate.getDate();

var N = 0;
now.setDate(myDate.getDate() + N);     //当前所在周一时间往后N天日期计算
var mm = (now.getMonth() + 1) < 10 ? "0" + (now.getMonth() + 1) : (now.getMonth() + 1); //格式化
var dd = now.getDate() < 10 ? "0" + now.getDate() : now.getDate();

posted @ 2014-08-18 20:41  way~  阅读(472)  评论(0编辑  收藏  举报