16 lines
368 B
JavaScript
16 lines
368 B
JavaScript
const timeElement = document.querySelector("#local-time");
|
|
|
|
function updateClock() {
|
|
const now = new Date();
|
|
timeElement.textContent = new Intl.DateTimeFormat("en-US", {
|
|
timeZone: "America/Detroit",
|
|
hour: "2-digit",
|
|
minute: "2-digit",
|
|
second: "2-digit",
|
|
hour12: false,
|
|
}).format(now);
|
|
}
|
|
|
|
updateClock();
|
|
window.setInterval(updateClock, 1000);
|