3 回答

TA贡献1818条经验 获得超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条经验 获得超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();
添加回答
举报