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

183
Views
How do I use .toLocaleTimeString() without displaying AM/PM?

How can I display a digital clock with the format "HH:MM" in Javascript?

The code below displays the digital clock in the format of "HH:MM AM/PM".

main.js

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

Edit: Although the code below works, I'd like to know if there is a way to do this via ".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

this way

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!