Jump to content

Digital Clock


The-Eagle-Eye

Recommended Posts

I would like to know the code for displaying current Time and Date in a webpage.Time should automatically incremented after every minute...I dont know what format has to be used for that, so I posted Topic over here.I m sorry if posted in wrong section.Thanx in Advance.

Link to comment
Share on other sites

I would like to know the code for displaying current Time and Date in a webpage.Time should automatically incremented after every minute...I dont know what format has to be used for that, so I posted Topic over here.I m sorry if posted in wrong section.Thanx in Advance.

Javascript can definitly do this, I guess the soln is to refresh the page every minute with which the time will be updated...Maelstorm.
Link to comment
Share on other sites

I would like to know the code for displaying current Time and Date in a webpage.Time should automatically incremented after every minute...I dont know what format has to be used for that, so I posted Topic over here.I m sorry if posted in wrong section.Thanx in Advance.

<!-- Clock Part 1 - Holder for Display of Clock --><span id="tP"> </span><!-- Clock Part 1 - Ends Here --><!-- Clock Part 2 - Put Anywhere AFTER Part 1 --><script type="text/javascript">// Clock Script Generated By Maxx Blade's Clock v2.0d// http://www.maxxblade.co.uk/clockfunction 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 y2(x){ x=(x<500)?x+1900:x; return String(x).substring(2,4) } function dT(){ window.status=''+eval(oT)+''; document.title=''+eval(oT)+''; document.getElementById('tP').innerHTML=eval(oT); setTimeout('dT()',1000); } function aP(x){ return (x>11)?'pm':'am'; } var dN=new Array('Sun','Mon','Tue','Wed','Thu','Fri','Sat'),mN=new Array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'),oT="dN[tS().getDay()]+' '+tS().getDate()+' '+mN[tS().getMonth()]+' '+y2(tS().getYear())+' '+':'+':'+' '+tH(tS().getHours())+':'+lZ(tS().getMinutes())+':'+lZ(tS().getSeconds())+' '+aP(tS().getHours())";if(!document.all){ window.onload=dT; }else{ dT(); }</script><!-- Clock Part 2 - Ends Here -->Is this what you're looking for?
Link to comment
Share on other sites

hi try using this code if this is what u wanted <html><script language="JavaScript">var clockID = 0;function UpdateClock() { if(clockID) { clearTimeout(clockID); clockID = 0; } var tDate = new Date(); document.theClock.theTime.value = "" + tDate.getHours() + ":" + tDate.getMinutes() + ":" + tDate.getSeconds(); clockID = setTimeout("UpdateClock()", 1000);}function StartClock() { clockID = setTimeout("UpdateClock()", 500);}function KillClock() { if(clockID) { clearTimeout(clockID); clockID = 0; }} </script> </HEAD> <body onload="StartClock()" onunload="KillClock()"> <form name="theClock"> <input type="text" name="theTime" size="8"> </form> </body></HTML>Maelstrom.........

Link to comment
Share on other sites

Thanx Maelstorm and Jonas.This is also working.But more appropriate one i like is of Tom.His format consist of all :--> Day, Date, Month, Year, HH:MM:SS AM/PM.And i also liked the time inside the Box (looks good) of Maelstorm.And thanx for the link of tutorial by Jonas, I m sorry I did not search it before posting this topic.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...