Skip to content

Instantly share code, notes, and snippets.

@brenna
Last active August 29, 2015 14:25
Show Gist options
  • Save brenna/cab7c241b79e25cc8a34 to your computer and use it in GitHub Desktop.
Save brenna/cab7c241b79e25cc8a34 to your computer and use it in GitHub Desktop.
convert HH:MM:SS format to seconds
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