datetime-local設置初始值


//全局變量

var format = "";

//構造符合datetime-local格式的當前日期
function getFormat(){
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 += ":";
format += nTime.getMinutes()<10?"0"+(nTime.getMinutes()):(nTime.getMinutes());
format += ":00";
}

$(function(){

  document.getElementById("endtime").value = format;//賦初始值

})

p.s:datetime-local必須格式化成"yyyy-MM-ddTHH:mm:ss"的格式

 

https://www.cnblogs.com/zmc-change/p/5674364.html

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM