I have a javascript program like:
function addtime() {
curtime = document.getElementById("time").value * 1000;
curtime += 1;
document.getElementById("time").value = curtime / 1000;
}
setInterval(function () {
addtime();
}, 1);
In my code, you can see that I multiply by 1000 and then divide by 1000, and this is because I want to increment by a millisecond every time, but show the number of seconds in the output of the div. But when I opened the page in which this code was, the second is not really the "second", if you understand what I mean. It is currently three times longer than usual, and I don’t know why.
So what is the problem in my code and what can I do to fix it?
thank
Lucas
source
share