updating online clock

This is a discussion on "updating online clock" within the JavaScript Forum section. This forum, and the thread "updating online clock are both part of the Program Your Website category.


 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Program Your Website > JavaScript Forum

Notices




Reply
 
LinkBack Thread Tools
  #1  
Old Mar 30th, 2007, 20:45
Reputable Member
Join Date: Mar 2007
Location: Kenya
Age: 20
Posts: 213
Thanks: 0
Thanked 0 Times in 0 Posts
Talking updating online clock

holl@ forumz

hope I will get some help here pliz .I once tried a clock on my web but it didnt update after every second only after you restart. anyone with a better code?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

  #2  
Old Mar 30th, 2007, 21:12
Daniel's Avatar
Elite Veteran
Join Date: Sep 2006
Location: The Kingdom of Rabbits
Age: 21
Posts: 2,051
Blog Entries: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Re: updating online clock

PHP: Select all

<html>
<
head>
<
script type="text/javascript">
function 
startTime()
{
var 
today=new Date()
var 
h=today.getHours()
var 
m=today.getMinutes()
var 
s=today.getSeconds()
// add a zero in front of numbers<10
m=checkTime(m)
s=checkTime(s)
document.getElementById('txt').innerHTML=h+":"+m+":"+s
t
=setTimeout('startTime()',500)
}
function 
checkTime(i)
{
if (
i<10
  {
i="0" i}
  return 
i
}
</script>
</head>
<body onload="startTime()">
<div id="txt"></div>
</body>
</html
Last Blog Entry: Assassin's Creed (Nov 22nd, 2007)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old Mar 31st, 2007, 02:22
Ryan Fait's Avatar
Elite Veteran
Join Date: May 2006
Location: Las Vegas
Posts: 3,787
Thanks: 0
Thanked 0 Times in 0 Posts
Re: updating online clock

Yes, JavaScript can do that, PHP can't.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4  
Old Mar 31st, 2007, 10:52
Reputable Member
Join Date: May 2006
Location: Northampton, UK
Posts: 399
Thanks: 0
Thanked 0 Times in 0 Posts
Re: updating online clock

moved to javascript forum
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5  
Old Mar 31st, 2007, 11:45
Reputable Member
Join Date: Mar 2007
Location: Kenya
Age: 20
Posts: 213
Thanks: 0
Thanked 0 Times in 0 Posts
Re: updating online clock

Quote:
Originally Posted by DanDoughty View Post
PHP: Select all

<html>
<
head>
<
script type="text/javascript">
function 
startTime()
{
var 
today=new Date()
var 
h=today.getHours()
var 
m=today.getMinutes()
var 
s=today.getSeconds()
// add a zero in front of numbers<10
m=checkTime(m)
s=checkTime(s)
document.getElementById('txt').innerHTML=h+":"+m+":"+s
t
=setTimeout('startTime()',500)
}
function 
checkTime(i)
{
if (
i<10
  {
i="0" i}
  return 
i
}
</script>
</head>
<body onload="startTime()">
<div id="txt"></div>
</body>
</html
wow this was so easy to you but very hard to me. thanx for ur time guys
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6  
Old Mar 31st, 2007, 11:46
Reputable Member
Join Date: Mar 2007
Location: Kenya
Age: 20
Posts: 213
Thanks: 0
Thanked 0 Times in 0 Posts
Re: updating online clock

it works now!!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #7  
Old Mar 31st, 2007, 13:37
Daniel's Avatar
Elite Veteran
Join Date: Sep 2006
Location: The Kingdom of Rabbits
Age: 21
Posts: 2,051
Blog Entries: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Re: updating online clock

Good

I'll let you in on a little secret:

http://www.w3schools.com/js/js_examples.asp

Last Blog Entry: Assassin's Creed (Nov 22nd, 2007)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #8  
Old Mar 31st, 2007, 19:43
Reputable Member
Join Date: Mar 2007
Location: Kenya
Age: 20
Posts: 213
Thanks: 0
Thanked 0 Times in 0 Posts
Re: updating online clock

cool I got that... Thanx
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
time

Thread Tools

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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
AJAX powered clock fl0w JavaScript Forum 3 Feb 8th, 2008 19:53
Webpage calender including clock satimis Web Page Design 0 Dec 28th, 2007 05:25
[SOLVED] Analog Clock in Flash student_in_training Flash & Multimedia Forum 9 Nov 10th, 2007 17:03
How to add a clock to your page! whiteknig863 Web Page Design 5 Jul 18th, 2007 14:27
Confusing Clock adrix Flash & Multimedia Forum 5 Aug 31st, 2006 14:26


All times are GMT. The time now is 09:10.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42