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 )