Solved

Countdown clock that resets automatically?

Posted on 2006-11-07
4
362 Views
Last Modified: 2009-12-16
I want to add a javascript clock to my web page that counts down DAILY from 8:00 until 17:00 EST... It should display the current date and time and the time left until 17:00...

Ex: November 7, 2007 11:35 EST ------- 5 Hours, 25 minutes remaining until ....

I can find scripts on the web that already do this. However, this repeats EACH day Monday thru Friday from 8:00 until 17:00... So at 8:00 the following day, the counter should reset and begin another cycle...

Ideally, I would want this to be automatic so I didn't have to change the ending date each day...

Any ideas on how I should proceed?
0
Comment
Question by:bfhiii
4 Comments
 
LVL 28

Expert Comment

by:Pravin Asar
ID: 17893548
<script language="javascript">
function NeedCntDown() {
var dt = new Date();
// Sunday = 0, Saturday = 6
// Do counter on Monday and Fridays
if (dt.getDay() == 1 || dt.getDay() == 5) {
   //
   // Your script goes here.
  //
}
</script>
0
 
LVL 23

Accepted Solution

by:
rama_krishna580 earned 250 total points
ID: 17903919
Hi,

<head>
<script LANGUAGE="JavaScript">
<!--
// Javascript Countdown
// Version 1.0 1/20/2000
// by TDavid at http://www.tdscripts.com/
var now = new Date();
var event = new Date("Sep 29 2001 00:00:01");
var seconds = (event - now) / 1000;
var minutes = seconds / 60;
var hours = minutes / 60;
var days = hours / 24;
ID=window.setTimeout("update();", 1000);
function update() {
now = new Date();
seconds = (event - now) / 1000;
seconds = Math.round(seconds);
minutes = seconds / 60;
minutes = Math.round(minutes);
hours = minutes / 60;
hours = Math.round(hours);
days = hours / 24;
days = Math.round(days);
document.form1.days.value = days;
document.form1.hours.value = hours;
document.form1.minutes.value = minutes;
document.form1.seconds.value = seconds;
ID=window.setTimeout("update();",1000);
}
// --></script>
</head>
<body>

<p><font face="Arial" size="3">Countdown To September 29, 2001, at 12:00: </font></p>
<form name="form1"><p>Days <input type="text" name="days" value="0" size="3"> Hours
<input type="text" name="hours" value="0" size="4"> Minutes <input type="text" name="minutes" value="0"
size="7"> Seconds <input type="text" name="seconds" value="0" size="7"> </p>
</form>

</body>
</html>

http://www.tdscripts.com/jscountdown.html

R.K
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Today I would like to talk about localizing (Internationalization) JavaScript applications. Introduction When creating an application that is going to be used by many people around the globe, it is important to remember that not everyone speak…
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…

920 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now