一段时间后我重新发现了 HTML。
我只使用 HTML 和 javascript 以及 Salesforce。我有两个日期输入字段。我很好奇是否有任何简单的方法可以用以下内容填充这些字段:今天的日期 B. 日期是今天之前 6 个月。
<input type="text" id="toDate" size="10" onmouseover="initialiseCalendar(this, 'toDate')"/>
Run Code Online (Sandbox Code Playgroud)
谢谢,卡尔文
填充今天的日期:
var today = new Date();
document.getElementById("toDate").value = today.getFullYear() + "-"
+ String(today.getMonth() + 101).slice(-2) + "-"
+ String(today.getDate() + 100).slice(-2);
Run Code Online (Sandbox Code Playgroud)
过去 6 个月:
var past = new Date();
past.setMonth(past.getMonth() - 6); //
document.getElementById("toOldDate").value = past.getFullYear() + "-"
+ String(past.getMonth() + 101).slice(-2) + "-"
+ String(past.getDate() + 100).slice(-2);
Run Code Online (Sandbox Code Playgroud)