当前位置: 主页 > js >

JS判断当前时间是否在某个区间之内

2021-01-19  |  来源:前端入门建站教程  |  作者:爱上编程

下面前端入门建站教程为大家介绍一下JS判断当前时间是否在某个区间之内

function isDuringDate(beginDateStr, endDateStr) {
    var curDate = new Date(),
        beginDate = new Date(beginDateStr),
        endDate = new Date(endDateStr);
    if (curDate >= beginDate && curDate <= endDate) {
        return true;
    }
    return false;
}
isDuringDate('2018/09/17', '2021/09/17');

上面是“JS判断当前时间是否在某个区间之内”的全面内容,想了解更多关于 js 文章,请继续关注前端入门建站教程。

最新文章

猜你喜欢