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);
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter