How can I display the date and time dynamically within a web page?
Created May 7, 2012
Nitesh Naveen Here is the code...
<html> <head> <title>Timer...</title> <script> function getDateTime() { var currDate = new Date(); dateDisplay = (eval(currDate.getMonth())+eval(1))+ "/"+currDate.getDate()+ "/"+currDate.getFullYear()+ " "+currDate.getHours()+":"+ currDate.getMinutes()+":"+ currDate.getSeconds(); return dateDisplay; } function putDate() { displayDate = getDateTime(); if(navigator.appName=="Netscape") { document.dateDisplayDiv.document.open(); document.dateDisplayDiv.document.write(displayDate); document.dateDisplayDiv.document.close(); } if(document.all) { document.all["dateDisplayTd"].innerHTML = displayDate } setTimeout("putDate()",1000); } </script> </head> <body onload="putDate()"> <table> <tr> <td id="dateDisplayTd"> <div id="dateDisplayDiv" name="dateDisplayDiv" style="position:relative;width:150;height:50" bgcolor=blue> </div> </td> </tr> </table> </body> </html>