100-project-100-days-website/100_projects/36-create-simple-clock/main.js
2023-03-29 02:33:41 +03:00
Ask

23 lines
536 B
JavaScript

{6fee1011fdf695fafc9ff359268b0facbdebb69b true 536 main.js 0xc001f7fa40}

function showTime() {
'use strict';
var now = new Date(),
hours = now.getHours(),
minutes = now.getMinutes(),
seconds = now.getSeconds();
if (hours < 10){
hours = '0' + hours;
}
if (minutes < 10){
minutes = '0' + minutes;
}
if (seconds < 10){
seconds = '0' + seconds;
}
document.getElementById('clock').textContent = hours + ':' + minutes + ':' + seconds;
};
window.onload = function(){
'use strict';
setInterval(showTime, 500);
};