I'm trying to find a stopwatch/count up timer in javascript that includes days, weeks, months, and years for my website.
I've tried finding this already but all of the things I found only had minutes and seconds.
One bit of code I've found that I've liked is this:
var minutesLabel = document.getElementById("minutes");
var secondsLabel = document.getElementById("seconds");
var totalSeconds = 0;
setInterval(setTime, 1000);
function setTime() {
++totalSeconds;
secondsLabel.innerHTML = pad(totalSeconds % 60);
minutesLabel.innerHTML = pad(parseInt(totalSeconds / 60));
}
function pad(val) {
var valString = val + "";
if (valString.length < 2) {
return "0" + valString;
} else {
return valString;
}
}
<label id="minutes">00</label>:<label id="seconds">00</label>
from this question: plain count up timer in javascript , but again this does not have days, weeks, months, and years.
Can someone rewrite this to have days, weeks, months, and years?
Also, this is not a duplicate.