Ho recuperato questo codice che cambia lo sfondo ad orari pre impostati
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="it">
<head>

<script type="text/javascript" language="JavaScript">

var now = new Date();
var hours = now.getHours();
var psj=0;

//18-19 night
if (hours > 17 && hours < 20){
document.write('<class="ts_12" style="background-color: #FF0000">')
}

//20-21 night
if (hours > 19 && hours < 22){
document.write('<body bgcolor="orangered" text="#FFFFFF">')
}

//22-4 night
if (hours > 21 || hours < 5){
document.write('<body bgcolor="black" text="#FFFFFF">')
}

//9-17 day
if (hours > 8 && hours < 18){
document.write('<body bgcolor="deepskyblue" text="#FFFFFF">')
}

//7-8 day
if (hours > 6 && hours < 9){
document.write('<body bgcolor="skyblue" text="#FFFFFF">')
}

//5-6 day
if (hours > 4 && hours < 7){
document.write('<body bgcolor="steelblue" text="#FFFFFF">')
}
//-->
</script>


</head>
<body >



<div align="center">




</div>










</body>

</html>
Se volessi impostarlo affinchè cambi il colore di una cella di una tabella, come devo fare?
La tabella col css che sono riuscito a creare è
<html><head><title>20 - 21</title><meta http-equiv="Content-Language" content="it"><meta http-equiv="Content-Type" content="text/html; charset=windows-1252"><script language="JavaScript" type="text/javascript">





var now = new Date();

var hours = now.getHours();

var psj=0;



//18-19 night

if (hours > 17 && hours < 20){

document.write('<class="ts_12" style="background-color: #FF0000">')

}



//20-21 night

if (hours > 19 && hours < 22){

document.write('<class ts_1 bgcolor="#008080">')

}



//22-4 night

if (hours > 21 || hours < 5){

document.write('<class ts_1 bgcolor="#008080">')

}



//9-17 day

if (hours > 8 && hours < 18){

document.write('<body bgcolor="deepskyblue" text="#FFFFFF">')

}



//7-8 day

if (hours > 6 && hours < 9){

document.write('<body bgcolor="skyblue" text="#FFFFFF">')

}



//5-6 day

if (hours > 4 && hours < 7){

document.write('<body bgcolor="steelblue" text="#FFFFFF">')

}

//--></script><style type="text/css">.ts_0 {border: 1px outset black; height: 52px; position: relative; text-align: left; width: 986px;} .ts_1 {height: 19px; left: 3px; padding: 1px; position: absolute; top: 3px; width: 89px;} .ts_2 {height: 19px; left: 98px; padding: 1px; position: absolute; top: 3px; width: 883px;} .ts_3 {height: 19px; left: 3px; padding: 1px; position: absolute; top: 28px; width: 89px;} .ts_4 {height: 19px; left: 98px; padding: 1px; position: absolute; top: 28px; width: 883px;}</style></head><body><div id="table1" class="ts_0"><div align="center" class="ts_1">20 - 21</div><div class="ts_2"> </div><div align="center" class="ts_3">22 - 23</div><div class="ts_4"> </div></div></body></html>

Ma non trovo il modo di farlo funzionare (sono totalmente inesperto)
Qualche consiglio?