Important alert: (current site time 7/15/2013 12:30:28 PM EDT)
 

VB icon

Another clock

Email
Submitted on: 8/11/2000 12:39:50 PM
By: John Oyston  
Level: Beginner
User Rating: By 2 Users
Compatibility: JavaScript
Views: 21051
(About the author)
 
     Another clock - click on the clock to get the date!
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
				
'**************************************
' Name: Another clock
' Description:Another clock - click on the clock to get the date!
' By: John Oyston
'
'This code is copyrighted and has' limited warranties.Please see http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=1916&lngWId=14'for details.'**************************************

<HTML>
<HEAD>
<TITLE>JavaScript Clock</TITLE>
<script Language="JavaScript">
<!-- Start // 
var timerID = null;
var timerRunning = false;
function stopclock(){
if(timerRunning)
clearTimeout(timerID);
timerRunning = false;
}
function showtime() {
var now = new Date();
var hours = now.getHours();
var minutes = now.getMinutes();
var seconds = now.getSeconds()
var timeValue = ((hours < 10) ? "0" : "") + hours
timeValue += ((minutes < 10) ? ":0" : ":") + minutes
timeValue += ((seconds < 10) ? ":0" : ":") + seconds
document.form.face.value = timeValue;
timerID = setTimeout("showtime()",1000);
timerRunning = true;
}
function showdate() {
var now = new Date();
var date = now.getDate();
var month = now.getMonth();
		var month=(month+1);
var year = now.getYear()
// MM/DD/YY;
var dateValue = ((month < 10) ? "0" : "") + month
dateValue += ((date < 10) ? "/0" : "/") + date
// DD/MM/YY;
// var dateValue = ((date < 10) ? "0" : "") + date
// dateValue += ((month < 10) ? "/0" : "/") + month
dateValue += "/" + year
stopclock();
document.form.face.value = dateValue;
delay(2);
startclock();
}
function startclock() {
// Just to be sure the clock has stopped;
stopclock();
showtime();
}
function delay(secs) {
count = 0;
while (count < (secs * 4000)) { count++ }
// 8000 ticks is approx. 1 second
}
// End -->
</script>
</head>
<BODY BGCOLOR="#00FFFF"onLoad="startclock()">
<FONT FACE=ARIAL COLOR="#000080"><CENTER>
<H1>JavaScript Clock</H1></CENTER>
<A HREF="mailto:960188@tigern.hsh.no">Jim Tage HENRIKSEN</A> sent me this elegant JavaScript Clock.<BR>
Click on the clock to get the date (MM DD YY format).<BR>
The time reappears in a few seconds.
<HR></FONT>
<form name="form">
<input type="button" name="face" value="00:00:00" onClick="showdate()">
</form>
<HR>
<CENTER>
<FONT FACE="Arial" COLOR="#000080" SIZE=4>
<A HREF="home.htm">Return to JavaScript Page</A>
<H5>John Oyston, (oyston@oyston.com), December 1997</H5></FONT></CENTER>
</BODY></HTML>


Other 25 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments
5/31/2002 5:03:04 PMKeith Hall

Wicked. I wanted to have a good clock for my site - and this is it. Thanks.
(If this comment was disrespectful, please report it.)

 
6/2/2002 11:53:01 PMAfif

It is cool....not bad....now i have a clock to replace my clock
(If this comment was disrespectful, please report it.)

 
10/31/2003 11:34:59 PM

It's cool!
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.