In this tutorial we will divide into various steps, In the first step, we are going to discuss how to display the current time and date.
It uses the browser time zone and displays the current time.
Tue Oct 20 2020 19:14:59 GMT+0530 (India Standard Time)
Step2: Now, It's time to creating a new Date() object
There are various ways to create date objects but we will use only one approach here.
var dt = new Date();
<h2>Kodlogs: Current Time and Date</h2>
<p>The current date and time:</p>
var d = new Date();
document.getElementById("kodlogs").innerHTML = d;
Kodlogs: Current Time and Date
The current date and time:
Tue Oct 20 2020 20:00:40 GMT+0530 (India Standard Time)