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

107
Views
momento js final de a partir de ahora volver solo en horas

¿Alguien sabe cómo puedo obtener en horas, no en días, este código a continuación devuelve 3 días, me gustaría devolver 72 horas?

 console.log(moment("2022-04-14T09:07:08.086Z").endOf('hours').fromNow(true))
 <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment.min.js"></script>

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

 const toHours = (days) => { days = days.substring(0, days.indexOf(' ')) return 24*days } console.log(toHours(moment("2022-04-14T09:07:08.086Z").fromNow(true)))
 <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment.min.js"></script>
O use el umbral relativo por momento (a veces incorrecto debido al redondeo)
 moment.relativeTimeThreshold('h', 24*26); console.log(moment("2022-04-14T09:07:08.086Z").endOf('hours').fromNow(true))
 <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment.min.js"></script>

about 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!