I want to add change css using current time. this is the Ilustration the code i want.
var today = new Date();
var hourNow = today.getHours();
var style; //add css//
if (hourNow > 0) { //hour 00:00 - 12:00 the css//
document.getElementsByTagName('BODY')[0].style.backgroundColor = "#fff";
document.getElementsByTagName('BODY')[0].style.color= "#505050"; }
else if (hourNow > 12) { //hour 120:00 - 18:00 the css//
document.getElementsByTagName('BODY')[0].style.backgroundColor = "gainsboro";
document.getElementsByTagName('BODY')[0].style.color= "black"; }
else if (hourNow > 18) { //hour 18:00 - 00:00 the css//
document.getElementsByTagName('BODY')[0].style.backgroundColor = "#1b1b1b";
document.getElementsByTagName('BODY')[0].style.color= "#fff"; }
else {
document.getElementsByTagName('BODY')[0].style.backgroundColor = "white";
document.getElementsByTagName('BODY')[0].style.color= "black";}
is that possible? i am new with JavaScript..