Time is not running

I realise this https://codepen.io/alpha_66/pen/JjzNdqx?editors=0010 the problem I have now is the time is not going (sorry for my english I m french guy) can I get a idea about what is going wrong ? thanks
5 Replies
MarkBoots
MarkBoots5mo ago
It is because you set the time only once. you need some sort of method to do it every second, for example with an interval function in your case, something like this
setInterval(()=>{
let actuel = new Date().toLocaleString();
temps.innerHTML = actuel;
}, 1000)
setInterval(()=>{
let actuel = new Date().toLocaleString();
temps.innerHTML = actuel;
}, 1000)
ref: https://developer.mozilla.org/en-US/docs/Web/API/setInterval
MarkBoots
MarkBoots5mo ago
No description
MarkBoots
MarkBoots5mo ago
and if you want to clean up your code a bit https://codepen.io/MarkBoots/pen/oNVWZEe
glutonium
glutonium5mo ago
side note, if u do call setInterval or setTimeout it's a good practice to also clear it using clearInterval or clearTimeout, so the dedicated section of the browser for running these functions know that it no longer has to worry about those
Pat66
Pat665mo ago
thanks