|
| ||||||||||
| Tags: clock, code, javascript, script |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| Create A Clock With Javascript
|
|
#2
| |||
| |||
| Re: Create A Clock With Javascript
I think you may need to use javascript books below to get this solution :
|
|
#3
| ||||
| ||||
| Re: Create A Clock With Javascript
The script below will provide you A clock in javascript: Code: <html>
<head>
<script type="text/javascript">
function time()
{
var now=new Date();
var hr=now.getHours();
var minute=now.getMinutes();
var s=now.getSeconds();
minute=checkTime(minute);
seconds=checkTime(seconds);
document.getElementById('txt').innerHTML=h+":"+minute+":"+seconds;
t=setTimeout('time()',500);
}
function checkTime(i)
{
if (i<10)
{
i="0" + i;
}
return i;
}
</script>
</head>
<body onload="time()">
<div id="txt"></div>
</body>
</html> |
|
#4
| ||||
| ||||
| Re: Create A Clock With Javascript
I have created the script below for getting clock in javascript. You canmake use of it. Code: <script type="text/javascript">
<!--
function updateClock ( )
{
var currt = new Date ( );
var currh = currt.getHours ( );
var currm= currt.getMinutes ( );
var currs = currt.getSeconds ( );
currm= ( currm< 10 ? "0" : "" ) + currm;
currs = ( currs < 10 ? "0" : "" ) + currs;
var timeOfDay = ( currh < 12 ) ? "AM" : "PM";
currh = ( currh > 12 ) ? currh - 12 : currh;
currh = ( currh == 0 ) ? 12 : currh;
var currtString = currh + ":" + currm+ ":" + currs + " " + timeOfDay;
document.getElementById("clock").firstChild.nodeValue = currtString;
}
// -->
</script> |
|
#5
| ||||
| ||||
| Re: Create A Clock With Javascript
Use the methods below to create your Javascript for getting the clock:
|
|
#6
| ||||
| ||||
| Re: Create A Clock With Javascript
You need to make use of the list below for javascript reference:
|
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "Create A Clock With Javascript" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to use javascript to create HTML and CSS | KennedII | Software Development | 5 | 22-02-2010 11:10 PM |
| Create calculator with the use of JavaScript | Jagdish Gada | Software Development | 3 | 14-11-2009 09:00 AM |
| JavaScript - How to create Element | Xylina | Software Development | 3 | 04-06-2009 05:06 PM |
| How to create analog clock using Small Basic | EricTheRed | Guides & Tutorials | 3 | 21-04-2009 06:34 PM |
| Create php alert pop ups using javascript. | Suzane | Software Development | 3 | 13-04-2009 03:39 PM |