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

182
Views
¿Cómo uso .toLocaleTimeString() sin mostrar AM/PM?

¿Cómo puedo mostrar un reloj digital con el formato "HH: MM" en Javascript?

El siguiente código muestra el reloj digital en el formato de "HH:MM AM/PM".

principal.js

 const d = new Date(); const cFormat = d.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit", });

Editar: aunque el código a continuación funciona, me gustaría saber si hay una manera de hacerlo a través de ".toLocaleTimeString()".

 const d = new Date(); const cFormat = d.toLocaleTimeString('en-US', {hour: "2-digit",minute: "2-digit"}); cFormat.replace("AM", "").replace("PM", ""); console.log( 'cFormat -> ', cFormat )

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

0

Por aquí

 const HH_MM = {hour: '2-digit', minute: '2-digit' } let cFormat = new Date() .toLocaleTimeString('en-US', HH_MM) .replace(/AM|PM/,'') console.log( 'cFormat -> ', cFormat )

about 4 years ago · Juan Pablo Isaza Report

0

let time = new Date().toLocaleTimeString().replace("AM", "").replace("PM", ""); console.log(time); //expected output //8:03:30
about 4 years ago · Juan Pablo Isaza Report

0

const d = new Date(); const cFormat = d.toLocaleTimeString('en-US', {hour: "2-digit",minute: "2-digit", hour12: true}); cFormat.replace("AM", "").replace("PM", ""); console.log( 'cFormat -> ', cFormat )
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!