Created
May 15, 2014 15:25
-
-
Save sdurandeu/abd674bd5b5b273a031a to your computer and use it in GitHub Desktop.
Minutes:Seconds Difference between two dates using UTC
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 startDateUtcMilliseconds = "2324324823" // In C#: (buildRun.Date.ToUniversalTime() - new DateTime(1970, 1, 1)).TotalMilliseconds.ToString(); | |
var hours, minutes, seconds; | |
if (rowItem.currentBuild) { | |
var startDate = new Date(parseInt(startDateUtcMilliseconds)); | |
var msec = Date.now() - startDate; | |
hours = Math.floor(msec / 1000 / 60 / 60); // discard | |
msec -= hours * 1000 * 60 * 60; | |
minutes = Math.floor(msec / 1000 / 60); | |
msec -= minutes * 1000 * 60; | |
seconds = Math.floor(msec / 1000); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment