本周一周末
程序员文章站
2022-05-15 09:53:51
...
/**本日 本周 本月**/
function handleDate(status) {
// 今天
let now = new Date();
let year = now.getFullYear();
let month = now.getMonth() + 1;
let week = now.getDay() || 7;
let day = now.getDate();
let nowTime = now.getTime();
let oneDayTime = 24 * 60 * 60 * 1000;
if (status == '1') {
let thisday = year + '-' + month + '-' + day;
$('.stime').val(thisday);
$('.etime').val(thisday);
} else if (status == '2') {
// 周一周末
let MondayTime = nowTime - (week - 1) * oneDayTime;//显示周一
let SundayTime = nowTime + (7 - week) * oneDayTime;//显示周日
let week1Date = new Date(MondayTime);
let week7Date = new Date(SundayTime);
let week1 = week1Date.getFullYear() + '-' + (week1Date.getMonth() + 1) + '-' + week1Date.getDate();
let week7 = week7Date.getFullYear() + '-' + (week7Date.getMonth() + 1) + '-' + week7Date.getDate();
$('.stime').val(week1);
$('.etime').val(week7);
} else if (status == '3') {
// 1月 12月
let month1 = year + '-1-1';
let month12 = year + '-12-31';
$('.stime').val(month1);
$('.etime').val(month12);
} else if (status == '4') {
// 本月
let max = [1, 3, 5, 7, 8, 10, 12];
let min = [4, 6, 9, 11];
let day = 1;
if (max.indexOf(month) >= 0) {
day = 31;
} else if (min.indexOf(month) >= 0) {
day = 30;
} else if (month == 2) {
if ((this.search.year % 4 == 0) && (this.search.year % 100 != 0)) {
day = 29;
} else {
day = 28;
}
}
let thismonth1 = year + month + '-1';
let thismonthend = year + month + '-' + day;
}
}
上一篇: jquery 插件实现瀑布流图片展示实例_jquery
下一篇: 分站系统怎么写