js 时间操作
now加n天
//返回yyyy-mm-dd格式 function getLocalTime(addNum) { var today, ms, thatDay, y, m, d, endDate; today = new Date().getTime(); ms = today + addNum * 24 * 60 * 60 * 1000; thatDay = new Date(ms); y = thatDay.getFullYear(); m = thatDay.getMonth() + 1; d = thatDay.getDate(); endDate = y + "-" + m + "-" + d; return endDate }
获取星期几
//输入yyyy-mm-dd function getWeekday(sDate) { var dt = new Date(sDate.replace(/-/g, '/')); var a = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六']; return a[dt.getDay()]; }