Update script.js
This commit is contained in:
parent
0510cdd20a
commit
7c53c58f80
1 changed files with 5 additions and 5 deletions
|
@ -1,12 +1,12 @@
|
||||||
function updateClock() {
|
function updateClock() {
|
||||||
const date = new Date();
|
let date = new Date();
|
||||||
const hours = date.getHours();
|
let hours = date.getHours();
|
||||||
const minutes = date.getMinutes();
|
let minutes = date.getMinutes();
|
||||||
const ampm = hours >= 12 ? 'pm' : 'am';
|
let ampm = hours >= 12 ? 'pm' : 'am';
|
||||||
hours = hours % 12;
|
hours = hours % 12;
|
||||||
hours = hours ? hours : 12;
|
hours = hours ? hours : 12;
|
||||||
minutes = minutes < 10 ? '0'+minutes : minutes;
|
minutes = minutes < 10 ? '0'+minutes : minutes;
|
||||||
const time = hours + ':' + minutes + ' ' + ampm;
|
let time = hours + ':' + minutes + ' ' + ampm;
|
||||||
document.getElementById('time').innerHTML = time;
|
document.getElementById('time').innerHTML = time;
|
||||||
setTimeout(updateClock, 1000);
|
setTimeout(updateClock, 1000);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue