I have this javascript timer and I want to get all the values for each time from my database. I want to add all the numbers together and get the final result. The problem is that my timer has a specific time format.
Code
let htmlTdTime = taskTimeRow.querySelectorAll("td:nth-child(2)");
htmlTdTime.forEach((time) => {
let time2 = time.innerHTML
let a2 = time2.split(":");
let seconds2 = +a2[0] * 60 * 60 + +a2[1] * 60 + +a2[2];
let ti2 = "";
function timer2() {
seconds2++;
let hours = Math.floor(seconds2 / 3600);
// Get minutes
let minutes = Math.floor((seconds2 - hours * 3600) / 60);
// Get seconds2
let secs = Math.floor(seconds2 % 60);
if (hours < 10) {
hours = `0${hours}`;
}
if (minutes < 10) {
minutes = `0${minutes}`;
}
if (secs < 10) {
secs = `0${secs}`;
}
let singleTime = time.innerHTML;
console.log(singleTime)
ti2 = `${hours}:${minutes}:${secs}`;
return ti2;
}
timer2();
})
// THIS IS WHAT I GET WHEN I CONSOLE.LOG
// 00:00:21
// 03:10:15
// 00:49:31
// 30:00:53
// 00:45:21
// 12:32:56
// 00:00:56