I have seen few post in here about this issue but I couldn't find the one as my case. So I have a table with three columns say column A, B and C where A and B includes dates in the form of "3/9/2016 4:28:42 PM". Column C is the difference of columns A and B. I got the difference but in milliseconds. I need each records of the column in days: hours: min format. I have seen one post Javascript show milliseconds as days:hours:mins without seconds but couldn't implement in my loop. Here is the JavaScript I am working on. How do I do it?
' SQL = some statements
<script>
$(function() {
ShowDifference();
ShowAverage();
});
function ShowDifference() {
var assigned;
var completed;
var difference;
$('#tbl tr').each(function() {
assigned = new Date($(this).find('.assigned').html())
completed = new Date($(this).find('.completed').html())
difference = completed - assigned;
// $(this).find('.difference').html(difference/1000/60/60);
$(this).find('.difference').html(difference);
});
}
function ShowAverage() {
var difference = Number(0);
var countRows = Number(0);
var average;
$('#tbl tr .difference').each(function() {
countRows = ($(this).html() !== '') ? countRows + 1 : countRows;
difference += Number($(this).html());
});
average = Number(difference / countRows);
$("#tbla #average").html(average);
}
</script>