
To get the current date and time in the JavaScript, follow this approach.
<script>
var d = new Date();
alert(d);
</script>
In the above code snippet, we have instantiated the Date
object (in built in JavaScript) and saved into the d
variable. Then using the alert method to show the value of d
.
OUTPUT