https://jsfiddle.net/8x7p682z/
function initialize() {
function setThemeForTimeOfDay() {
const body = document.querySelector('body');
const hours = new Date().getHours();
if (9 <= hours && hours <= 12)
body.style['background-color'] = 'linear-gradient(to right, rgb(39, 38, 38), rgb(96, 231, 255),rgb(39, 38, 38))';
if (hours > 12 && hours <= 15)
body.style['background-color'] = 'linear-gradient(to right, rgb(39, 38, 38), rgb(96, 255, 207),rgb(39, 38, 38))';
else
body.style['background-color'] = 'linear-gradient(to right, rgb(39, 38, 38), rgb(96, 255, 207),rgb(39, 38, 38))';
}
function initialize1() {
function setThemeForTimeOfDay() {
const body = document.querySelector('body');
const hours = new Date().getHours();
if (9 <= hours && hours <= 12)
body.style['background-color'] = 'linear-gradient(to right, rgb(39, 38, 38), rgb(96, 231, 255),rgb(39, 38, 38))';
if (hours > 12 && hours <= 15)
body.style['background-color'] = 'linear-gradient(to right, rgb(39, 38, 38), rgb(96, 255, 207),rgb(39, 38, 38))';
else
body.style['background-color'] = 'linear-gradient(to right, rgb(39, 38, 38), rgb(96, 255, 207),rgb(39, 38, 38))';
}
setThemeForTimeOfDay();
setInterval(setThemeForTimeOfDay, 60000);
}
These are my codes. I implemented javascript to modify the background color and navbar selection color depending on the user's time. However, it is not working as expected. Can someone please assist me with this issue? I am completely new to this.