Last active
August 29, 2015 14:25
-
-
Save brenna/cab7c241b79e25cc8a34 to your computer and use it in GitHub Desktop.
convert HH:MM:SS format to seconds
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
convertToSeconds(niceValue){ | |
var durations = niceValue.split(':').reverse(); | |
return durations.reduce((prev, curr, i) => { | |
return Number(prev) + Number(curr) * Math.pow(60, i); | |
}); | |
}, | |
convertToSeconds('01:26:45'); //returns 5205 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment