3 回答

TA貢獻1818條經(jīng)驗 獲得超3個贊
嘗試為其添加默認日期
document.getElementById("creation-from-date").value = setDefautValue();
function setDefautValue() {
var date = new Date(); // today
date.setUTCHours(0, 0, 0, 0); //set default time 00:00 AM
const dStr = date.toISOString()
// remove seconds and milliseconds
return dStr.substring(0, dStr.indexOf(':', dStr.indexOf(':')+1))
}

TA貢獻1836條經(jīng)驗 獲得超3個贊
您可以嘗試使用Javascript日期:
$("creation-from-date").val(new Date().toLocalString());
// toLocalString() will return the local time while toISOString() will return the UTC time.
這里是一個不錯的jQuery擴展,對于初始化datetime和datetime-local輸入非常有用:
// To initialize, simply call the method:
$('input[type="datetime-local"]').setNow();
添加回答
舉報