[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Countdown clock that resets automatically?

Posted on 2006-11-07
4
Medium Priority
?
379 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 29

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 1000 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
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…

649 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