Created
January 31, 2016 12:47
-
-
Save SteKoe/868c4ffbf8ce8b55c732 to your computer and use it in GitHub Desktop.
Convert a given time string hh:mm:ss to the actual 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
// E.g.: 02:09:07 will result in 7747 seconds | |
timeStr.split(':') | |
.reverse() | |
.map((part, idx) => Math.pow(60, idx) * +part) | |
.reduce((prev, cur) => prev + cur, 0); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment