Created
April 28, 2015 02:40
-
-
Save haribote/55f7258fa5d3a6e77270 to your computer and use it in GitHub Desktop.
Translate a "hh:mm:ss" format text to seconds
This file contains hidden or 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
"01:24:36".split(":").reverse().reduce(function(memo, value, index) { | |
memo += parseInt(value, 10) * Math.pow(60, index); | |
return memo; | |
}, 0); | |
// => 5076 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment