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

235
Views
How Do I Convert Timestamp to Number of Days in JavaScript/React

Please I received a response from a REST API, and in the JSON object, the time value was a timestamp. However, I need to render it as a "number of days" kind of format.

I received this particular time stamp: "2022-01-12T13:05:16Z"

I want to render it as something like "5 days ago"

How do I go about this please?

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

0

transform the current date and the date you want to milliseconds with .getTime() then subtract it then split the result to milliseconds in a day and you get the number of days passed, Math.ceil to round the number up

console.log(Math.ceil((new Date().getTime() - new Date("2022-01-12T13:05:16Z").getTime()) / 86400000))

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!