-4
var d = new Date();
var time = d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate() + " " + d.getHours() + ":" + d.getMinutes();
document.getElementById("currentDay").innerHTML = time;
Phil
  • 141,914
  • 21
  • 225
  • 223
  • Specifically look at [this answer](https://stackoverflow.com/a/51738434/4604701) on the above question. – fubar May 10 '21 at 00:12

1 Answers1

-1

Try putting your code in an interval. That way, it will be called every second.

setInterval(() => {

    //Your code here

},1000);
M-Coder
  • 80
  • 6