The diffDate() function takes a start date and an end date and returns the human readable form. For example : 41 mins, 53 secs
var varStartDate = new Date();
// Do some things here
var varEndDate = new Date();
var varTotalTime = diffDate(varStartDate, varEndDate);
print (varTotalTime);
function diffDate (startDate, endDate)
{
var varRegex_Time = new RegExp("^(.+?)\\.(.+)$");
var varRegex_Truncate = new RegExp("^\\, (.+)$");
varStart = (startDate != undefined) ? startDate.getTime() : 0;
varEnd = (endDate != undefined) ? endDate.getTime() : 0;
diff = varEnd - varStart;
secs = Math.floor(diff / 1000 % 60);
mins = Math.floor(diff / (1000 * 60) % 60);
hours = Math.floor(diff / (1000 * 60 * 60) % 24);
days = Math.floor(diff / 86400000);
secsText = (secs > 1) ? ", " + String(secs).replace(varRegex_Time, "$1") + " secs" : "";
minsText = (mins > 1) ? ", " + String(mins).replace(varRegex_Time, "$1") + " mins" : "";
hoursText = (hours > 1) ? ", " + String(hours).replace(varRegex_Time, "$1") + " hours" : "";
daysText = (days > 1) ? String(days).replace(varRegex_Time, "$1") + " days" : "";
return String(daysText + hoursText + minsText + secsText).replace(varRegex_Truncate, "$1");
}