JavaScript > Date

Date & Time in JavaScript

How to get current date and time in the JavaScript?


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

 Views: 5307 | Post Order: 98



Write for us






Hosting Recommendations