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();
再爱,代码也不能是生活的全部。每天看书-每天运动-每天关注健康-每天了解时尚-每天进步一点点。