Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

139
Views
How to calculate time from a point of time in past to present using moment library

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");
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!