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

723
Views
moment.js ¿Cómo obtener la hora exacta de los segundos?

Tengo un temporizador en mi proyecto, tengo formato de hora en segundos 90000 Quiero transformar segundos en horas y minutos (HH:mm) usando moment.js, me pregunto como puedo obtener la hora exacta, si el tiempo es menor a 86399 moment funciona como se esperaba, pero mi objetivo es obtener ese resultado 25:00 , ¿es esto posible con moment?

 const secs = 90000; const formatted = moment.utc(secs*1000).format('HH:mm'); document.write(formatted);
 <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.min.js"></script>

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

0

No es posible con moment ya que moment funciona con formatos de 12/24 horas. Sin embargo, puedes usar matemáticas básicas

 const formatMMSS = (timeInSeconds) => { const time = (timeInSeconds/60/60).toFixed(2) const hh = time.split('.')[0] let mm = (parseFloat('0.'+time.split('.')[1])*60).toString().split('.')[0] if(mm.length == 1){ mm = '0'+mm } return hh+':'+ mm; } console.log(formatMMSS(90000));

about 4 years ago · Juan Pablo Isaza Report

0

Prueba esto

 var seconds = 90000; // multiply by 1000 because Date() requires miliseconds var date = new Date(seconds * 1000); var hh = date.getUTCHours(); var mm = date.getUTCMinutes(); var ss = date.getSeconds(); // If you were building a timestamp instead of a duration, you would uncomment the following line to get 12-hour (not 24) time // if (hh > 12) {hh = hh % 12;} // These lines ensure you have two-digits if (hh < 10) {hh = "0"+hh;} if (mm < 10) {mm = "0"+mm;} if (ss < 10) {ss = "0"+ss;} // This formats your string to HH:MM:SS var t = hh+":"+mm+":"+ss; document.write(t); // result 1:00:00
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!