?
Solved

Special clock...?

Posted on 2003-11-09
2
Medium Priority
?
243 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 600 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

771 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