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

277
Vistas
get plural value for time units (days, hours, minutes) using Intl API

I'm trying to localize time units and I'm able to do so for singular (hour, day, minute) but I'm unable to find any way to figure out the plural equivalent (hours, days, minutes). Is it not supported or am I missing something obvious. I looked at Intl.PluralRules thinking that'd be helpful but with no luck. Would appreciate any tips.

let locale = "en-US";
let days = new Intl.DisplayNames(locale, { type: 'dateTimeField', style: 'long' }).of('day');
let hours = new Intl.DisplayNames(locale, { type: 'dateTimeField', style: 'long' }).of('hour');
console.log(days,hours);

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You should take a look at Intl.RelativeTimeFormat.prototype.formatToParts(). This method returns three parts of a RelativeTimeFormat, last one of which is an object with time unit.

const rtf1 = new Intl.RelativeTimeFormat('en', { numeric: 'auto' });
const parts = rtf1.formatToParts(10, 'seconds');

console.log(parts[2].value);
// expected output: " seconds"
about 4 years ago · Juan Pablo Isaza 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