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

127
Views
Moment.js pluralisation of hours

Is it possible to make a plural form of hour and hours through momentjs? Or maybe something native from Intl.

I looking for something like this, because I need localization as well.

moment.specialFunction({hours: 1}); // 1 hour
moment.specialFunction({hours: 2}); // 2 hours
moment.locale("ru").specialFunction({hours: 1}); // 1 час

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

0

This can be achieved using Intl.NumberFormat:

console.log(
  Intl.NumberFormat('en-GB', { style: 'unit', unit: 'hour', unitDisplay: 'long' }).format(12),
  Intl.NumberFormat('ru', { style: 'unit', unit: 'hour', unitDisplay: 'long' }).format(12),
  Intl.NumberFormat('en-US', { style: 'unit', unit: 'hour', unitDisplay: 'long' }).format(1),
  Intl.NumberFormat('ru', { style: 'unit', unit: 'hour', unitDisplay: 'long' }).format(1),
)

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!