if anyone is interested i created an active clock (with the help of other scripts). i wanted to have a clock on my site but i didnt like any of the javascripts that were available. they were all based on the time of the user's computer. most of the time those clocks are wrong. including mine 🙂 so i made a script that uses the time of the server (not that the server's time is always accurate). it also displays the date. when the clock hits midnight, the page reloads displaying the new date and day. i THINK it is flawless but if anyone finds any problems let me know. theglow1@excite.com. also, i dont need credit for this. but if you do plan on using it just let me know what you think. just a thank you would be nice. 🙂 ok here is the script. -phil
<head>
<script>
function reload() {
var timeID = setTimeout("location.href = document.URL", 0)
}
</script>
</head>
<body bgcolor="#0047D5" text="#AAD554">
<font face="arial, verdana, helvetica, default" size="-2">
<?php
$hour = date("H");
$minute = date("i");
$second =date("s");
?>
<span id="clock" style="position:absolute; left: 45px; top: 65px; width: 200px; height: 50px;"></span>
<script language="JavaScript">
/* BIG TIMER
// edited by Jason C. Chapman
with basic interface code borrowed from the following script:
//::::::::::: DIGITAL CLOCK SCRIPT :::::::::::\\
by Micah Goulart
This script can be used as long as this
disclaimer is left untouched.
For bug reports or custom scripts , email me at:
micahgoulart@mailbr.com.br
//::::::::::: copyright 1999 :::::::::::\\
Micah's script is available for free download from: http://www.zdnet.com/devhead/resources/scriptlibrary/javascript/scripts/0403
also with the basic timer code borrowed from the following script:
// Script name: TRACKING TIME SPENT
// Script Editor: Howard Chen
// Browser Compatible for the script: IE 2.0 or Higher
// Netscape 2.0 or Higher
// This script is free as long as you keep its credits
Howard's script is available for free download from: http://www.zdnet.com/devhead/resources/scriptlibrary/javascript/scripts/0065
NOTE FROM THE EDITOR:
To set the record straight: I (Jason Chapman) did very little of the programming for this script on my own.
Except for minor alterations, rearranging, and combining the two above scripts, I did very little coding on my own.
It was my understanding that these scripts are available in the free domain as long as the above notices are included.
The basic interface, including the size and positioning of the numbers, is from the Digital Clock script.
The functions for timing the usage of the web page are from the Tracking Time Spent script.
*/
var entered = new Date();
function time() {
if (!document.layers && !document.all) return
var now = new Date();
var seconds = Math.floor((now.getTime() - entered.getTime()) / 1000) + <?php echo $second ?>;
var minutes = Math.floor(seconds /60) + <?php echo $minute ?>;
var hours = Math.floor(minutes /60) + <?php echo $hour ?>;
var seconds = seconds % 60
var minutes = minutes % 60
var hours = hours % 60
var amorpm = "AM";
if (hours == "24" && minutes == "0" && seconds == "0") reload();
if (hours == "0") hours = 12;
if (hours > 11) amorpm = "PM";
if (hours > 12) hours = hours - 12;
if (hours <= 9) hours = "0" + hours;
if (minutes <= 9) minutes = "0" + minutes;
if (seconds <= 9) seconds = "0" + seconds;
digclock = "<font face='arial, verdana, helvetica, default' size='-2'>" + hours + ":" + minutes + ":" + seconds + " " + amorpm + " <?php echo date('T') . '<br>' . date('l F j, Y') ?></font>";
if (document.layers){
document.layers.clock.document.write(digclock);
document.layers.clock.document.close();
}
else if (document.all) clock.innerHTML = digclock;
setTimeout("time()",1000)
}
window.onload = time;
</script>
</font>
</body>