Skip to content

Instantly share code, notes, and snippets.

@rustedwolf
Created June 19, 2017 10:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rustedwolf/fdf712a423e5ec26f00cb13cc4d510d4 to your computer and use it in GitHub Desktop.
Save rustedwolf/fdf712a423e5ec26f00cb13cc4d510d4 to your computer and use it in GitHub Desktop.
Simple time string convertion to seconds with miliseconds included
function strToSeconds(timeStr) {
const strParts = timeStr.split(':').reverse();
let time = parseFloat(strParts[0]);
time += parseInt(strParts[1]) * 60;
if (!!strParts[2])
time += parseInt(strParts[2]) * 3600;
return time;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment