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

246
Views
How to remove time count from intervalToDuration in date-fns

How to remove time countdown from intervalToDuration in date-fns?

 let duration = intervalToDuration({
    start: new Date('2022-03-24'),
    end: new Date(),
  });

  const newD = formatDuration(duration, {
    delimiter: ', ',
  });
  console.log(newD);

From the above function result is 6 months, 5 days, 4 hours, 8 minutes, x seconds

What I'm expecting is 6 months, 5 days

almost 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You'll have to adjust the dates used to calculate the duration.

In case you want to change the formatted output, not the duration itself:

formatDuration accepts a format in its options: https://date-fns.org/v2.29.3/docs/formatDuration

E.g.

formatDuration(
  {
    months: 9,
    days: 7,
    hours: 5,
    minutes: 9,
    seconds: 30
  },
  { format: ['months', 'days'] }
)
almost 4 years ago · Santiago Trujillo 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!