Solved

Special clock...?

Posted on 2003-11-09
2
240 Views
Last Modified: 2008-03-06
Can I make a clock that starts off the same as the server time, but then runs twice as fast as a clock in reality? Also it would have to print the data onto a page.
0
Comment
Question by:JavaHead_Jonnie
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 19

Accepted Solution

by:
Michael701 earned 150 total points
ID: 9712106
sure why not,

<html>
<head>
<script type="text/javascript">
var timer = null

<?PHP
$now=getdate();
echo "var hours = ".$now['hours']."\n";
echo "var minutes = ".$now['minutes']."\n";
echo "var seconds = ".$now['seconds']."\n";
?>
function start_clock()
{
timer = setTimeout("update_clock()",1000)
}

function stop_clock()
{
clearTimeout(timer)
}

function update_clock()
{
  if (seconds < 59)
    seconds++
  else
  {
    seconds=0
    if (minutes < 59)
       minutes++
    else
    {
      minutes=0
      if (hours < 12)
        hours++
      else
        hours=1
    }
  }
document.forms["clock"].display.value = hours + ":" + ((minutes < 10) ? "0" : "") + minutes + ":" + ((seconds < 10) ? "0" : "") + seconds
timer = setTimeout("update_clock()",1000) //********* change this to 500 to make the clock run twice as fast
}
</script>
</head>
<body onload="start_clock()" onunload="stop_clock()">
<form name="clock">
<input type="text" name="display" size="10">
</form>
</body>
</html>
0
 

Author Comment

by:JavaHead_Jonnie
ID: 9715825
Thanks, it works a treat! It's just what I wanted.
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question