//构造符合datetime-local格式的当前日期 function getFormat(hours, minutes, second) { format = ""; var nTime = new Date(); format += nTime.getFullYear() + "-"; format += (nTime.getMonth() + 1) < 10 ? "0" + (nTime.getMonth() + 1) : (nTime.getMonth() + 1); format += "-"; format += nTime.getDate() < 10 ? "0" + (nTime.getDate()) : (nTime.getDate()); format += "T"; //format += nTime.getHours() < 10 ? "0" + (nTime.getHours()) : (nTime.getHours()); format += hours; format += ":"; //format += nTime.getMinutes() < 10 ? "0" + (nTime.getMinutes()) : (nTime.getMinutes()); format += minutes; format += ":" + second; }