Reputation: 55
for the below code I got the error NaN:
for (let item of this.list) {
if (item.pin.length == 2) {
var inTime = item.pin[0].time;
var outTime = item.pin[1].time;
var timeDuration = outTime - inTime;
}
}
Upvotes: 0
Views: 37
Reputation: 168
You could use the date object in javascript. Just convert both strings into the a date using something like this:
inTime = new Date(item.pin[0].time);
outTime = new Date(item.pin[1].time);
timeDuration = outTime - inTime;
In this case, the timeDuration
will be in milliseconds.
Upvotes: 2