Solved

Special clock...?

Posted on 2003-11-09
2
239 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
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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
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…

825 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