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

225
Views
How can I get the difference in the two dates in js which are in string?

I have a certain format which is in the

{
    "updatedAt": "2022-01-04 22:41:32.268897",
    "status": "open",
    "createdAt": "2022-01-04 22:41:26.328339"
}

I want to get the difference in hours or minutes of both the dates I tried many but didn't get the expected result.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can use the Date module in javascript.

const obj = { "updatedAt": "2022-01-04 22:41:32.268897", "status": "open", "createdAt": "2022-01-03 22:41:26.328339" };

const updatedAt = new Date(obj.updatedAt);
const createdAt = new Date(obj.createdAt);

const diffInMilliSecs = updatedAt - createdAt;

This difference is in milliseconds. You can now convert this into seconds or minutes or hours.

about 4 years ago · Juan Pablo Isaza Report
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!