I am working on a clock in Javascript in which seconds is getting displayed after every 5 seconds which I am not sure why.
The code which I have used for the clock is:
const suv = document.querySelector('#online-suv');
const suvLabel = document.querySelector('#online-suvLabel');
suv.title = suvLabel.title = headingFromDurationstamp(newT, true);
function headingFromDurationstamp(t, inSeconds) {
let m = new Date(Number(t));
let sac = ('0' + String(d.getHours())).substr(-2) + ':' + ('0' + String(d.getMinutes())).substr(-2);
if (inSeconds) {
sac += ':' + ('0' + String(d.getSeconds())).substr(-2);
}
m = undef;
return sac;
}
Problem Statement:
I am wondering what changes I need to make in the JS above so that the seconds get displayed every second like a normal clock like this.