전단에서 jq로 날짜와 날짜를 계산하는 방법

1938 단어
        $("#btn_search")
            .click(function () {
                SearchUser();
            });
         
        $("#ShowToday")
            .click(function () {
                $("#SceneRecordStarTime").val(gettime(0));
                $("#SceneRecordEndTime").val(gettime(0));
                SearchUser();
            });
        $("#ShowSevendays")
            .click(function () {
                $("#SceneRecordStarTime").val(gettime(-7));
                $("#SceneRecordEndTime").val(gettime(0));
                SearchUser();
            });
        $("#ShowThirtydays")
            .click(function () {
                $("#SceneRecordStarTime").val(gettime(-30));
                $("#SceneRecordEndTime").val(gettime(0));
                SearchUser();
            });
        $("#ShowSixtydays")
            .click(function () {
                $("#SceneRecordStarTime").val(gettime(-60));
                $("#SceneRecordEndTime").val(gettime(0));
                SearchUser();
            });
    });

    // 
    function getnowtime() {
        var nowtime = new Date();
        var year = nowtime.getFullYear();
        var month = (nowtime.getMonth() + 1);
        var day = (nowtime.getDate());
        var datetime = year + "-" + (month < 10 ? "0" + month : month) + "-" + (day < 10 ? "0" + day : day);
        return datetime;
    }
    // 
    function gettime(days) {
        var dd = new Date();
        dd.setDate(dd.getDate() + days); // days 
        var y = dd.getFullYear();
        var m = (dd.getMonth() + 1) < 10 ? "0" + (dd.getMonth() + 1) : (dd.getMonth() + 1); // , 10 0
        var d = dd.getDate() < 10 ? "0" + dd.getDate() : dd.getDate(); // , 10 0
        return y + "-" + m + "-" + d;
    }

좋은 웹페이지 즐겨찾기