I need to calculate the exact time diffrence using moment JS .
My JS code is :
var a = moment(from_url);
a.format('DD/MM/YYYY hh:mm:ss');
var b = moment(to_url);
b.format('DD/MM/YYYY hh:mm:ss');
console.log("from URL")
var from_hours = from_url()
console.log(b.diff(a, 'minutes')) //
console.log(b.diff(a, 'hours')) //
console.log(b.diff(a, 'days')) //
console.log(b.diff(a, 'weeks')) //
console.log("Time interval: "+b.diff(a, 'days')+ " days "+ b.diff(a, 'hours') +" hours " +b.diff(a, 'minutes')+" mintes");
Now,
from_url = '2016-05-03T08:00:00';
to_url = '2016-05-04T09:00:00';
Now, for these timings, I am getting output as :
Time interval: 1 days 25 hours 1500 minutes
It is converting everything to the days (1 day ~25 hours).
However, the output that I want is : 1 day 1 hour 0 minutes.
Can anyone please help me in this ? I am newbie to JS and unable to figure this out. Thanks.