JS判断2个时间是否在同一周

function isSameWeek(old, now) {
    var oneDayTime = 1000 * 60 * 60 * 24;
    var old_count = parseInt(+old / oneDayTime);
    var now_other = parseInt(+now / oneDayTime);
    return parseInt((old_count + 4) / 7) == parseInt((now_other + 4) / 7);
}  

function compareDate(date1, date2) {
    var oDate1 = new Date(date1);
    var oDate2 = new Date(date2);
    if (oDate1.getTime() >= oDate2.getTime()) {
        return true;
    } else {
        return false;
    }
}

你可能感兴趣的:(javascript)