To get the current date and time in JavaScript, use the getDate() method.
Example
You can try to run the following code get the date and time:
<!DOCTYPE html>
<html>
<body>
<p>Today's Date and Time</p>
<button onclick="myFunction()">Get Date & Time</button>
<p id="test"></p>
<script>
function myFunction() {
var date = new Date();
document.getElementById("test").innerHTML = date;
}
</script>
</body>
</html>