Skip to content

Instantly share code, notes, and snippets.

@byeblogs
Created August 31, 2018 11:00
Show Gist options
  • Save byeblogs/c3fff35c376c3a84b0c49c8ecccbf27d to your computer and use it in GitHub Desktop.
Save byeblogs/c3fff35c376c3a84b0c49c8ecccbf27d to your computer and use it in GitHub Desktop.
Check diff range of hours, minutes, second in Javascript..
var startTime = moment('12:00:01', 'hh:mm:ss a');
var endTime = moment('13:00:10' , 'hh:mm:ss a');
var totalHours = (endTime.diff(startTime, 'hours'));
var totalMinutes = endTime.diff(startTime, 'minutes');
var clearMinutes = totalMinutes % 60;
console.log(totalHours + " hours and " + clearMinutes + " minutes");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment