Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Running clock

Posted on 2006-05-08
10
Medium Priority
?
275 Views
Last Modified: 2007-12-19
Right now I am displaying the time on an inline frame which refreshes every second.

The code I am using on the frame page is asp:
OffsetTime = TimeValue(dateadd("h", -1, Now()))

Is there a way I can make a running clock that I do not have to do a page refresh?  As you can imagine all those hits every second would not make my web host too happy =)
0
Comment
Question by:JuniorBee
  • 4
  • 4
  • 2
10 Comments
 
LVL 63

Expert Comment

by:Zvonko
ID: 16632211
Show the output format you get on the page from the upper ASP value.
0
 

Author Comment

by:JuniorBee
ID: 16632480
10:34:04 AM
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 16634896
Here an example:

<html>
<head>
<title>Zvonko &#42;</title>
<style>
#timeDiv {
  color: blue;
  font: bold 36px Courier;
}
</style>
<script>
function showTime(){
  var aTime = new Date();
  document.getElementById("timeDiv").innerHTML=aTime.toLocaleString().split(aTime.getFullYear())[1];
  setTimeout(showTime, 1000);
}
window.onload=showTime;
</script>
</head>
<body>
<center><div id="timeDiv"></div></center>
</body>
</html>

0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 2

Expert Comment

by:mangesh004
ID: 16637770
Hi,

This will  freak you out.

Why dont you go for a analog clock .... It will look good

Just put following code in your home page

<SCRIPT LANGUAGE="JavaScript">var clocksize=100;</SCRIPT>
<SCRIPT SRC="http://gheos.net/js/clock.js"></SCRIPT>

ref: http://gheos.net/js/clock/

Regards,
Mangesh
0
 

Author Comment

by:JuniorBee
ID: 16637888
Cool!  But I don't have too much room.  It would only be like 25 pixels tall. Not too easy on the eyes =)
0
 

Author Comment

by:JuniorBee
ID: 16637896
Zvonko, that's lovely!  How can I offset the time by -1 hours?
0
 
LVL 2

Expert Comment

by:mangesh004
ID: 16637918
Hi,
           I downloaded its clock.js file. It has follwoing code
---------------------------------------------------------------------------------
var clocksize;
if(!clocksize||clocksize=='SIZE')clocksize='100';

document.write('<OBJECT CLASSID="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" CODEBASE="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH="'+clocksize+'" HEIGHT="'+clocksize+'">');

document.write('<PARAM NAME="movie" VALUE="http://www.gheos.net/js/clock/clock.swf">');
document.write('<PARAM NAME="quality" VALUE="high">');
//document.write('<PARAM NAME="bgcolor" VALUE="#FFFFFF">');
document.write('<PARAM NAME="wmode" VALUE="transparent">');
document.write('<PARAM NAME="menu" VALUE="false">');

document.write('</OBJECT>');

-------------------------------------------------------------------

and you can seee that it uses swf oject to dispaly as clock

visit this link http://www.gheos.net/js/clock/clock.swf and you will see the clock

i explored it later

have a look

Regards,
Mangesh
0
 
LVL 63

Accepted Solution

by:
Zvonko earned 2000 total points
ID: 16640484
Like this:

<html>
<head>
<title>Zvonko &#42;</title>
<style>
#timeDiv {
  color: blue;
  font: bold 36px Courier;
}
</style>
<script>
function showTime(){
  var xT = new Date();
  xT.setHours(xT.getHours() + (-1));
  document.getElementById("timeDiv").innerHTML=xT.toLocaleString().split(xT.getFullYear())[1];
  setTimeout(showTime, 1000);
}
window.onload=showTime;
</script>
</head>
<body>
<center><div id="timeDiv"></div></center>
</body>
</html>

Or in ASP:


<html>
<head>
<title>Zvonko &#42;</title>
<style>
#timeDiv {
  color: blue;
  font: bold 36px Courier;
}
</style>
<script>
function showTime(){
  var xT = new Date();
  <% offsetHours = -1 %>
  xT.setHours(xT.getHours() + (<% = offsetHours %>));
  document.getElementById("timeDiv").innerHTML=xT.toLocaleString().split(xT.getFullYear())[1];
  setTimeout(showTime, 1000);
}
window.onload=showTime;
</script>
</head>
<body>
<center><div id="timeDiv"></div></center>
</body>
</html>









0
 

Author Comment

by:JuniorBee
ID: 16644463
Great work!!  Just wondering, is this grabbing the date from the users computer or from the server?
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 16646119
The time is fetched from browser.
It is corrected by the offset set by server in the ASP script.

0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

580 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