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