Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

240
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda