JSFiddle - React, Tailwind, and code Playground
by Göran Andersson
JavaScript
var intime = '00:30:05';
var out = '01:07:40';
function toSeconds(s) {
var p = s.split(':');
return parseInt(p[0], 10) * 3600 + parseInt(p[1], 10) * 60 + parseInt(p[2], 10);
}
function fill(s, digits) {
s = s.toString();
while (s.length < digits) s = '0' + s;
return s;
}
var sec = toSeconds(intime) + toSeconds(out);
var result =
fill(Math.floor(sec / 3600), 2) + ':' +
fill(Math.floor(sec / 60) % 60, 2) + ':' +
fill(sec % 60, 2);
alert(result);