Created
June 16, 2016 11:06
-
-
Save dsincl12/60d04251bca4b04c41a597e8280d0aa8 to your computer and use it in GitHub Desktop.
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
var calculateElapsedTime = function (startTime, endTime) { | |
var milliseconds = endTime - startTime; | |
var seconds = Math.round(milliseconds / 1000); | |
var minutes = Math.floor(seconds / 60); | |
var hours = minutes > 59 ? Math.floor(minutes / 60) : 0; | |
if (minutes > 0) { | |
seconds -= minutes * 60; | |
} | |
if (minutes > 59) { | |
minutes -= hours * 60; | |
} | |
return { | |
hours: hours, | |
minutes: minutes, | |
seconds: seconds | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment