Created
June 19, 2017 10:55
-
-
Save rustedwolf/fdf712a423e5ec26f00cb13cc4d510d4 to your computer and use it in GitHub Desktop.
Simple time string convertion to seconds with miliseconds included
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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