zadaca-web-site/html/main.js

19 lines
531 B
JavaScript

function updateBackgroundColor() {
const now = new Date();
const hours = now.getHours();
let color = "#FFFFFF";
if (hours >= 6 && hours < 12) {
color = "#FFFAE3";
} else if (hours >= 12 && hours < 18) {
color = "#C7E9FB";
} else if (hours >= 18 && hours < 21) {
color = "#FFB87A";
} else {
color = "#1E1E30";
}
document.body.style.backgroundColor = color;
}
window.onload = () => {
updateBackgroundColor();
setInterval(updateBackgroundColor, 60000);
};