Convert HH:MM:SS string to seconds only in javascript

Try this:

var hms="02:04:33";   // your input string
var a = hms.split(':'); // split it at the colons

// minutes are worth 60 seconds. Hours are worth 60 minutes.
var seconds = (+a[0]) * 60 * 60 + (+a[1]) * 60 + (+a[2]); 

console.log(seconds);

Leave a Comment