Having some issues with calculating a date time range. What im trying to accomplish is to have moment provide me the difference in hours.
For example, here is my script:
var startTime = $('2016-02-21 18:00');
var endTime = $('2016-02-21 19:30');
var hours = moment(endTime, 'YYYY/MM/DD HH:mm').diff(moment(startTime, 'YYYY/MM/DD HH:mm')).duration().asHours();
console.log(hours);
I am expecting that my console.log(hours)
returns something like 1.5 (estimated in hours). But instead it's returning this error:
Uncaught TypeError: moment(...).diff(...).duration is not a function
at <anonymous>:5:90
at Object.InjectedScript._evaluateOn (<anonymous>:895:140)
at Object.InjectedScript._evaluateAndWrap (<anonymous>:828:34)
at Object.InjectedScript.evaluate (<anonymous>:694:21)
Would anyone have any ideas?
Heres a full example here https://jsfiddle.net/ewmq6sof/.