//获取当前时间 function nowTime() { var myTime = new Date(); //当前时间 var myYear = myTime.getFullYear(); //获取完整的年份(4位,1970-????) var myMonth = (myTime.getMonth() + 1)<10?'0'+(myTime.getMonth() + 1):myTime.getMonth() + 1; //获取当前月份(0-11,0代表1月) var myData = myTime.getDate()<10?'0'+myTime.getDate():myTime.getDate(); //获取当前日(1-31) var myHours = myTime.getHours()<10?'0'+myTime.getHours():myTime.getHours(); //获取当前小时数(0-23) var myMinutes = myTime.getMinutes()<10?'0'+myTime.getMinutes():myTime.getMinutes(); //获取当前分钟数(0-59) var mySeconds = myTime.getSeconds()<10?'0'+myTime.getSeconds():myTime.getSeconds(); //获取当前秒数(0-59) return myYear + '-' + myMonth + '-' + myData+' '+myHours+':'+myMinutes+':'+':'+mySeconds; }