For a chat application, I want to calculate the duration of time after last interaction. I have tried diff & from methods available in moment-js library, but doesn't seem to be getting the right answer. I need the duration in seconds.
let lastInteracted = '2021-12-04T18:30:00.000Z';
let currentTime = new moment();
1st method:
let durationAfterLastInteraction = moment(lastInteracted).from(currentTime)
2nd method:
let durationAfterLastInteraction = moment.duration(currentTime.diff(moment(lastInteracted))).as("seconds");