废话不多说,直接上代码
/**
* 判断当前时间是否在指定日期范围内
* @Author: Lai Chengliang
* @Date: 2022/04/24 16:02
* @param date [beginDateStr] [开始日期] yyyy/MM/dd
* @param date [endDateStr] [结束日期] yyyy/MM/dd
* @return Boolean
*/
export const isDuringDate = (beginDateStr, endDateStr) => {
const curDate = new Date();
const beginDate = new Date(beginDateStr);
const endDate = new Date(endDateStr);
if (curDate >= beginDate && curDate <= endDate) {
return true;
}
return false;
};