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

Training Mode Regular Fastrack Crash
Classroom | Online
Course Description :
Solution :

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

<input type="date" id="currentDate">

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

<input type="time" id="currentDate">

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