Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

difference between two time

// start time and end time
var startTime = moment('12:16:59 am', 'HH:mm:ss a');
var endTime = moment('06:12:07 pm', 'HH:mm:ss a');

// calculate total duration
var duration = moment.duration(endTime.diff(startTime));

// duration in hours
var hours = parseInt(duration.asHours());

// duration in minutes
var minutes = parseInt(duration.asMinutes()) % 60;

alert(hours + ' hour and ' + minutes + ' minutes.');
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #difference #time
ADD COMMENT
Topic
Name
4+3 =