How to use Javascript time()?
<p>Below is my code to show a calender for today using the <code>date.gettime</code> method evaluate the time. The <code>refreshtime()</code> function makes the time dynamic, but it is not working. Why?</p>

<pre><code>&lt;html&gt;
&lt;head&gt;
&lt;script type="text/javascript"&gt;
   function refreshtime() {
       var timeis=gettime()
       document.getElementById("clock").innerHTML=timeis
   }

   function gettime() {
       var time=new Date()
       var hour=time.getHours()
       if(hour&lt;12)
           var ampm="am"
       else
           ampm="pm"
       var minute=time.getMinutes()
       var seconds=time.getSeconds()
       var text=hour+':'+ minute+':'+seconds+ampm
       return text
   }
   function nameofmonth(month) {  
       var monthname=new Array("January","February","March","April","May","June","July","August","September","October","November","December")
       return monthname[month]
   }  
   function monthdays(month,year) {
       var daysofmonth=new Array(31,28,31,31,30,31,31,31,30,31,30,31)
       if(year%4==0)
           daysofmonth[1]=29  
       return daysofmonth[month]   
   }
   function table() {
       var now=new Date()
       var hour=now.getHours()
       var minute=now.getMinutes()
       var second=now.getSeconds()
       var date=now.getDate()
       var month=now.getMonth() 
       var year=now.getFullYear()
       now.setFullYear(year,month,1)
       var firstday=now.getDay()
       var monthname=nameofmonth(month)
       var daysofmonth=monthdays(month,year)
       if(firstday&gt;0)
           var k=-(firstday-1)
       else
           k=1
       var table="&lt;table border=5 cellspacing=9 cellpadding=17&gt;"
       table +="&lt;th colspan=7&gt;"+monthname+" "+date+"th&lt;/th&gt;"
       table +="&lt;tr&gt;&lt;th&gt;sun&lt;/th&gt;&lt;th&gt;mon&lt;/th&gt;&lt;th&gt;tue&lt;/&gt;&lt;th&gt;wed&lt;/th&gt;&lt;th&gt;thu&lt;/th&gt;&lt;th&gt;fri&lt;/&gt;&lt;th&gt;sat&lt;/th&gt;&lt;/tr&gt;"
       for(var i=0;i&lt;5;i++) {
           table+="&lt;tr&gt;"
           for(var j=0;j&lt;7;j++) {
               if(k&lt;=daysofmonth &amp;&amp; k&gt;0) {
                   if(k==date)
                       table+='&lt;td id="clock" bgcolor="aqua"&gt;'+k+'&lt;br&gt;'+gettime()+ '&lt;/td&gt;'
                   else
                       table+='&lt;td&gt;'+k+'&lt;/td&gt;'
                   k=parseInt(k)
               }
               else
                   table+="&lt;td&gt;&lt;/td&gt;"
               k++
           }
           table+="&lt;/tr&gt;"
       }
       table+="&lt;/table&gt;"
       document.write(table)
   }      
 &lt;/script&gt; 
 &lt;/head&gt;
 &lt;body onload="table();setInterval('refreshtime()',1000)")
 &lt;/body &gt;
 &lt;/html&gt;
</code></pre>
