Created
October 16, 2015 11:49
-
-
Save fahimbabarpatel/723513de3f40ebddf38c to your computer and use it in GitHub Desktop.
convert hours minutes seconds 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
var hms = '02:04:33'; // your input string | |
var a = hms.split(':'); // split it at the colons | |
// minutes are worth 60 seconds. Hours are worth 60 minutes. | |
var seconds = (+a[0]) * 60 * 60 + (+a[1]) * 60 + (+a[2]); | |
console.log(seconds); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment