The Input Date object represents an HTML <input> element with type="date".
We can access an <input> element with type="date" by using document.getElementById()
:
var x = document.getElementById("myDate");
Click the button to get the date of the date field.
<!DOCTYPE html> <html> <body> <input type="date" id="myDate" value="2020-02-09"> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {/*from w w w . j av a 2 s .c o m*/ var x = document.getElementById("myDate").value; document.getElementById("demo").innerHTML = x; } </script> </body> </html>