You can try :
const clock = document.querySelector('where you want to output the time');
function setDate() {
const now = new Date();
const seconds = now.getSeconds();
const minutes = now.getMinutes();
const hours = now.getHours();
clock.innerHTML = hours + ":" + minutes + ":" + seconds;
}
setInterval(setDate, 1000);
new Date() Allows you to get the current time
getSeconds(), getMinutes(), getHours() Allows you to get the seconds, minutes and hours out of the date you put before. Here the date is now and you refresh the clock every second via setInterval(setDate, 1000) so you basically refresh & display the current time every second with that function.