Update script.js

This commit is contained in:
Kainoa Kanter 2022-03-05 14:02:30 -08:00 committed by GitHub
parent 0510cdd20a
commit 7c53c58f80
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,12 +1,12 @@
function updateClock() {
const date = new Date();
const hours = date.getHours();
const minutes = date.getMinutes();
const ampm = hours >= 12 ? 'pm' : 'am';
let date = new Date();
let hours = date.getHours();
let minutes = date.getMinutes();
let ampm = hours >= 12 ? 'pm' : 'am';
hours = hours % 12;
hours = hours ? hours : 12;
minutes = minutes < 10 ? '0'+minutes : minutes;
const time = hours + ':' + minutes + ' ' + ampm;
let time = hours + ':' + minutes + ' ' + ampm;
document.getElementById('time').innerHTML = time;
setTimeout(updateClock, 1000);
}