How to calculate number of days and hours difference between 2 days in AngularJS
dueOnDate: "2017-05-30T08:30:10.123+02:00"
currentDate: "2016-05-30T09:30:10.123+02:00"
Is there any inbuilt Angular function to achieve this?
Thanks in advance
How to calculate number of days and hours difference between 2 days in AngularJS
dueOnDate: "2017-05-30T08:30:10.123+02:00"
currentDate: "2016-05-30T09:30:10.123+02:00"
Is there any inbuilt Angular function to achieve this?
Thanks in advance
As Robg said, you are currently dealing with a string which makes it more difficult to do calculations with. First thing I would do is start using the momentjs library which is very good for working with dates.
Then I would have a look at this question about hour difference, or this question and the answers because I think they have everything in them you need.
An example is:
var then = "04/09/2013 15:00:00";
var now = "02/09/2013 14:20:30";
var duration = moment.duration(then.diff(now));
var hours = duration.asHours();