function isDuringDate () {
var curDate = new Date() //当前时间
if (curDate >= new Date('2021-5-18 00:00') && curDate <= new Date('2022-5-18 08:30'))return true
if (curDate >= new Date('2021-5-18 10:00') && curDate <= new Date('2021-5-18 16:30'))return true
if (curDate >= new Date('2021-5-18 20:00') && curDate <= new Date('2021-5-18 23:30'))return true
}
console.log(isDuringDate())
var a = new Date() //当前时间
console.log(a.getDate(0))
function getWeekTime() {
const one_day = 86400000;// 24 * 60 * 60 * 1000;
const date = new Date();
const day = date.getDay();// 返回0-6,0表示周日
// 设置时间为当天的0点
date.setHours(0);
date.setMinutes(0);
date.setSeconds(0);
date.setMilliseconds(0);
const week_start_time = new Date(date.getTime() - (day - 2) * one_day);
const week_end_time = new Date(date.getTime() + (7 - day) * one_day);
return {
week_start_time,
week_end_time
}
}
console.log(getWeekTime())
console