To change a css style depending on time of day (javascript)
<p>im trying to write a little .js file to change a css style from <code>display:block</code> to <code>display:none</code> depending on the time of day, 08.30 to 17.00 display block and 17.00 to 08.30 display none.</p>

<p>Here's what i have so far:</p>

<pre><code>&lt;script language="JavaScript"&gt;
day=new Date()     //..get the date
x=day.getHours()    //..get the hour

if(x&gt;=8.30 &amp;&amp; x&lt;17) {

  document.write('&lt;style type="text/css"&gt;#live{display:block}"&gt;&lt;/style&gt;')

 } else

 if(x&gt;=17 &amp;&amp; x&lt;8.30) {

   document.write('&lt;style type="text/css"&gt;#live{display:none}"&gt;&lt;/style&gt;')

};

&lt;/script&gt;
</code></pre>

<p>Do think this is good js plus not sure if using 8.30 would work plus not sure if the last ";" is needed.</p>

<p>Any help on this would be great thanks.</p>

<p>Im now trying this code but does not work</p>

<pre><code>&lt;script type="text/javascript"&gt;
$(document).ready ( function (){

var dateObj = new Date();
var hour = dateObj.getHours() * 100 + dateObj.getMinutes();

if (hour &gt;= 1600 &amp;&amp; hour &lt;= 1800) {
document.getElementById('live').style.display = "none";
 }


 });

 &lt;/script&gt;
</code></pre>
