Jquery当前日期的前一天

概述

日期加减,前后N天均可

代码

// 开始时间默认当前日期的前一天,结束时间默认为当前日期!!
        $(function() {
            var currentDate = new Date().format("yyyy-MM-dd hh:mm:ss");
            //currentdateStr = currentDate.toLocaleString(); //2016-08-04 11:29:15
            //var currentTime = currentDate.toLocaleTimeString();
            //alert(currentTime);
            //$("#passRecordEndTime").val(currentDate);
            var currentTime = currentDate.toLocaleString().substring(11);
            //alert(currentTime);

            var now = new Date();
            //alert(now.toLocaleString());
            now = new Date(now.getTime() - 86400000);
            var yyyy = now.getFullYear(), mm = (now.getMonth() + 1).toString(), dd = now
                    .getDate().toString();
            if (mm.length == 1) {
                mm = '0' + mm;
            }
            if (dd.length == 1) {
                dd = '0' + dd;
            }
            //alert(yyyy + '-' + mm + '-' + dd+' '+currentTime);
            //$("#passRecordStartTime").val(yyyy + '-' + mm + '-' + dd+' '+currentTime);
        });

你可能感兴趣的:(Java,Web)