HTML Display Current date

Here’s one way. You have to get the individual components from the date object (day, month & year) and then build and format the string however you wish.

n =  new Date();
y = n.getFullYear();
m = n.getMonth() + 1;
d = n.getDate();
document.getElementById("date").innerHTML = m + "/" + d + "/" + y;
<p id="date"></p>

Leave a Comment