日期中前一天和后一天

function Previousday() {

    var curDate = new Date(CreateDate_Temp);
    var preDate = new Date(curDate.getTime() - 24 * 60 * 60 * 1000);

    var strDate = preDate.getFullYear() + "-";
    strDate += preDate.getMonth() + 1 + "-";
    strDate += preDate.getDate() + "-";
    strDate += preDate.getHours() + ":";
    strDate += preDate.getMinutes() + ":";
    strDate += preDate.getSeconds();
    $("#CreateDate").datebox("setValue", strDate);
    CreateDate_Temp = $('#CreateDate').datebox('getValue');
}
function NextDay() {

    // var nextDate = new Date(curDate.getTime() + 24*60*60*1000);
    var curDate = new Date(CreateDate_Temp);
    var nextDate = new Date(curDate.getTime() + 24 * 60 * 60 * 1000);

    var strDate = nextDate.getFullYear() + "-";
    strDate += nextDate.getMonth() + 1 + "-";
    strDate += nextDate.getDate() + "-";
    strDate += nextDate.getHours() + ":";
    strDate += nextDate.getMinutes() + ":";
    strDate += nextDate.getSeconds();
    $("#CreateDate").datebox("setValue", strDate);
    CreateDate_Temp = $('#CreateDate').datebox('getValue');
}

  

原文地址:https://www.cnblogs.com/suhaihong/p/8533741.html