Solved

Countdown clock that resets automatically?

Posted on 2006-11-07
4
364 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

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…
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
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…

777 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