javascript获取系统时间

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));//今天
});

上一篇:Oracle中表的四种连接方式讲解


下一篇:vue项目 sockjs-node一直报错问题