Get hours difference between two dates in Moment Js
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();
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();
I believe you are looking for the query functions, isBefore, isSame, and isAfter. But it’s a bit difficult to tell exactly what you’re attempting. Perhaps you are just looking to get the difference between the input time and the current time? If so, consider the difference function, diff. For example: moment().diff(date_time, ‘minutes’) A few other … Read more
Use this to transform a moment object into a date object: From http://momentjs.com/docs/#/displaying/as-javascript-date/ moment().toDate(); Yields: Tue Nov 04 2014 14:04:01 GMT-0600 (CST)