Created
January 18, 2017 16:49
-
-
Save X-Raym/53b5e6ca55744265045bd8f846ea1ce7 to your computer and use it in GitHub Desktop.
Parse TimeCode 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 string = "40:01.456"; | |
| var time_array = string.split(':'); | |
| time_array = time_array.reverse(); | |
| console.log( time_array ); | |
| console.log( 'length', time_array.length ); | |
| var multiply = [1, 60, 3600]; | |
| var seconds = 0; | |
| for( i=0; i < time_array.length; i++) { | |
| console.log( time_array[i] + '*' + multiply[i] + '+' + seconds ) | |
| seconds = time_array[i] * multiply[i] + seconds; | |
| } | |
| console.log( seconds ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment