Get hours difference between two dates in Moment Js

Solution 1:

You were close. You just need to use the duration.asHours() method (see the docs).

var duration = moment.duration(end.diff(startTime));
var hours = duration.asHours();

Solution 2:

Following code block shows how to calculate the difference in number of days between two dates using MomentJS.

var now = moment(new Date()); //todays date
var end = moment("2015-12-1"); // another date
var duration = moment.duration(now.diff(end));
var days = duration.asDays();
console.log(days)