如何将今天的日期设置为默认日期并在 INTEL XDK 中每天更改?

how to set today's date as default and will change everyday in INTEL XDK?

我正在开发一个应用程序,该应用程序的输入字段为 DATE
每天都会更改, 基于显示数据的日期。

I got the solution to my problem in HTML5 Input Type Date -- Default Value to Today? this discussion .

但是当我尝试在英特尔 XDK 中编写代码时,它不显示今天的日期。这是代码。

var date = new Date();

var day = date.getDate();
var month = date.getMonth() + 1;
var year = date.getFullYear();

if (month < 10) month = "0" + month;
if (day < 10) day = "0" + day;

var today = year + "-" + month + "-" + day;       
document.getElementById("theDate").value = today;
<input type="date" id="theDate">

我在我的项目中尝试过相同的代码。但它给出的结果像

提前致谢......

Moment.js 很有帮助 Moment.js 帮助了我。感谢您的回复.. :)

  1. 首先将 Moment.js 文件导入您的代码。
  2. document.getElementById('today').value = moment().format('YYYY-MM-DD');
  3. 在自动加载页面的单独函数中使用上面的代码。

感谢回复。