Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save sdurandeu/abd674bd5b5b273a031a to your computer and use it in GitHub Desktop.
Save sdurandeu/abd674bd5b5b273a031a to your computer and use it in GitHub Desktop.
Minutes:Seconds Difference between two dates using UTC
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