Update index.html
This commit is contained in:
parent
db4b226342
commit
b5b6ef5006
1 changed files with 16 additions and 1 deletions
17
index.html
17
index.html
|
@ -32,6 +32,21 @@
|
|||
<!-- Feel free to add more divs here -->
|
||||
</div>
|
||||
</div>
|
||||
<script src="scr/script.js"></script>
|
||||
<script>
|
||||
function updateClock() {
|
||||
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;
|
||||
let time = hours + ':' + minutes + ' ' + ampm;
|
||||
document.getElementById('time').innerHTML = time;
|
||||
setTimeout(updateClock, 1000);
|
||||
}
|
||||
|
||||
updateClock();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Reference in a new issue