Created
June 29, 2014 21:41
-
-
Save Ciantic/cc28a36bd40a5d3f3493 to your computer and use it in GitHub Desktop.
Format time HH:MM
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
| // total in seconds | |
| function formatTime(total: number): string { | |
| // If the number is float ceiling gives best result | |
| var total = Math.ceil(total), | |
| mins = Math.floor(total / 60), | |
| secs = Math.floor(total - mins * 60), | |
| m = ("000" + mins).slice(-2), | |
| s = ("000" + secs).slice(-2); | |
| return m + ":" + s; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment