Sunday, January 23, 2011

Display clock Your html page

Display clock using javasript:

java script header section code:

function tS(){ x=new Date(); x.setTime(x.getTime()); return x; }
function lZ(x){ return (x>9)?x:'0'+x; }
function tH(x){ if(x==0){ x=12; } return (x>12)?x-=12:x; }
function dT(){ if(fr==0){ fr=1; document.write(''+eval(oT)+''); } document.getElementById('tP').innerHTML=eval(oT); setTimeout('dT()',1000); }
function aP(x){ return (x>11)?'pm':'am'; }
var fr=0,oT="tH(tS().getHours())+':'+lZ(tS().getMinutes())+':'+lZ(tS().getSeconds())+' '+aP(tS().getHours())";


inside the html page add below this code (Add where ever you want display clock):

'<'script language="JavaScript">dT();'<'/
script>

No comments:

Post a Comment