How to set current time and date in html input value by js

Solution :

Step1 :
First Step is to put id ="currentDate"  in your html date input like this :
 <input id="currentDate" type="date" />

Step2 : Same as first Step is to put id ="currentTime"  in your html time input like this :
<input id="currentDate" type="time" />

Step3 :  Paste this below code in your html file before closing body tag

var date = new Date();
var currentDate = date.toISOString().slice(0,10);
var currentTime = date.getHours() + ':' + date.getMinutes();

document.getElementById('currentDate').value = currentDate;
document.getElementById('currentTime').value = currentTime;

I hope this code will help you, enjoy coding....

Request a Demo