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


i'm working on application have input field date.
changes daily, based on date data displayed.

i got solution problem in html5 input type date -- default value today? discussion .

but when tried code in intel xdk .its not displaying todays date . here code.

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">

i have tried same code in project . gives result likeenter image description here

thanks in advance.....

moment.js helpful moment.js helped me. replies .. :)

  1. first import moment.js file code.
  2. document.getelementbyid('today').value = moment().format('yyyy-mm-dd');
  3. use above piece of code in separate function page gets automatically loaded.

thanks replies.


Comments