function GetDateStr(AddDayCount) {
var dd = new Date();
dd.setDate(dd.getDate()+AddDayCount);
var year = dd.getFullYear();
var month = dd.getMonth()+1+"";
if(month.length<2)month="0"+month;
var day = dd.getDate()+"";
if(day.length<2)day="0"+day;
var hour = dd.getHours()+"";
if(hour.length<2)hour="0"+hour;
var minutes = dd.getMinutes()+"";
if(minutes.length<2)minutes="0"+minutes;
var seconds = dd.getSeconds()+"";
if(seconds.length<2)seconds="0"+seconds;
return year+"-"+month+"-"+day+" "+hour+":"+minutes+":"+seconds;
}
$(document).ready(function(){
$("#startTime").val(GetDateStr(-1));//昨天
$("#endTime").val(GetDateStr(0));//今天
});
时间: 2024-11-05 11:55:44