I am trying to get date from input and print only date on but something is wrong with my code Please help me to rectify it.
Here is the code:
var input = document.getElementById("dateInput").value;
var d = new Date(input);
document.getElementById("demo").innerHTML = d.getDate();
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript get Date</h2>
<input type="date" id="dateInput" />
<p>The Date is:</p>
<p id="demo"></p>
</body>
</html>