I need to calculate work hours between two Date. I set up two date.
var startDate = new Date("2/25/2017 20:30");
var endDate = new Date ("3/28/2017 20:58");
I set up days like objects in which i have work start and work end.
var monday = {"start":"09:00", "end":"17:00"};
var tuesday = {"start":"09:00", "end":"17:00"};
var wednesday = {"start":"09:00", "end":"17:00"};
var thursday = {"start":"09:00", "end":"17:00"};
var friday = {"start":"08:00", "end":"13:00"};
var saturday = {"start":"08:00", "end":"11:00"};
var sunday = {"start":"08:00", "end":"09:00"};
Then i put all objects in array:
var workDays = [monday, tuesday, wednesday, thursday, friday, saturday, sunday];
I don't know how to subtract hours in each day. For example, in monday: 17:00 - 09:00 = 8 hours.
I tried this:
var mondayStart = monday.start;
var mondayEnd= monday.end;
In console i get right start and end time of monday object, but i have problem with subtraction.
var mondayDifference = mondayEnd - mondayStart;
console.log(mondayDifference);
But, in console i get: NaN (not a number).
I'll be thankfull for any hints or help.