eridian_clock/js/scripts.js

22 lines
496 B
JavaScript

function earthTime() {
let date = new Date();
let hours = date.getUTCHours()
let minutes = date.getUTCMinutes()
let seconds = date.getUTCSeconds()
document.getElementById("clock").innerText =
appendLeadingZeros(((hours * 3600) + (minutes * 60) + seconds).toString(6));
setTimeout(function () {
earthTime()
}, 1000);
}
function appendLeadingZeros(time) {
while (time.length < 7) {
time = "0" + time;
}
return time;
}
earthTime();