IT Community - Software Programming, Web Development and Technical Support

How do I write a clock program in JavaScript?

This is a discussion on How do I write a clock program in JavaScript? within the HTML, CSS and Javascript Coding Techniques forums, part of the Web Development category; Hi all... How do I write a clock program in JavaScript? Thanks & Regards itbarota....


Go Back   IT Community - Software Programming, Web Development and Technical Support > Web Development > HTML, CSS and Javascript Coding Techniques

Register FAQ Members List Calendar Mark Forums Read
  #1  
Old 09-13-2007, 02:25 AM
itbarota itbarota is offline
D-Web Architect
 
Join Date: Jun 2007
Posts: 542
itbarota is on a distinguished road
Default How do I write a clock program in JavaScript?

Hi all...

How do I write a clock program in JavaScript?

Thanks & Regards
itbarota.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2  
Old 09-13-2007, 03:25 AM
Pvinothkumar Pvinothkumar is offline
D-Web Analyst
 
Join Date: Sep 2007
Posts: 235
Pvinothkumar is on a distinguished road
Default Re: How do I write a clock program in JavaScript?

Hi.......

A simple clock program would retrieve a new Date() every second (or, better yet, several times a second) and then display the time information from the Date() object. The following code displays a clock on the browser's status bar:

function sbClock() {
var DateString=(new Date()).toString();
self.status=DateString.substring(0,3+DateString.la stIndexOf(':'));
setTimeout("sbClock()",200);
}
sbClock();

Thanks......
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3  
Old 10-12-2007, 09:55 PM
kingmaker kingmaker is offline
D-Web Genius
 
Join Date: Jun 2007
Posts: 881
kingmaker is on a distinguished road
Send a message via MSN to kingmaker
Default Re: How do I write a clock program in JavaScript?

<script language="javascript">
var dateform
speed=1000
len=28
tid = 0;

function dodate()
{
f.date.value=new Date();
tid=window.setTimeout("dodate()",speed);
}

function start(x) {
f=x
tid=window.setTimeout("dodate()",speed);
}

function cleartid() {
window.clearTimeout(tid);
}

// for some reason on some pages this crashes netscape
function Clock()
{
document.write('<FORM name=dateform><input name=date size=')
document.write(len)
document.write(' value="Clock: Requires Javascript"></FORM>')
start(document.dateform);
}
// end-->
</script>
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
can we write a c program for a elctronics product? saravanan C and C++ Programming 4 12-18-2008 06:30 PM
Clock on a webpage that syncs with the Atomic clock. itbarota HTML, CSS and Javascript Coding Techniques 1 03-16-2008 07:33 PM
How do I write a file from JavaScript? itbarota HTML, CSS and Javascript Coding Techniques 5 10-26-2007 12:54 AM
How can I write Arabic characters in my Javascript? Pvinothkumar HTML, CSS and Javascript Coding Techniques 1 09-13-2007 11:44 PM
How to write Bluetooth Connection program in c# for Windows mobile 5.0 ? theone Windows Mobile 0 07-15-2007 11:16 PM


All times are GMT -7. The time now is 07:07 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.
Our Partners
One Way Moving Companies | Stamford Dentist | Euro Millions Lottery | Home Loans| Furniture

SEO by vBSEO 3.0.0