www.webdeveloper.com
Results 1 to 4 of 4

Thread: Countdown

Hybrid View

  1. #1
    Join Date
    Oct 2013
    Posts
    3

    Countdown

    Hello Guys n Girls.
    I have a problem. I am an OKish web designer (i taught myself stuff) any way. I am looking for a java script code that counts down to a certain hour monday-thursday and then counts down to a different hour on friday (i dont care about the weekends) Monday-Thursday it has to count down to 2:00 pm and friday it counts down to 12 pm PLEASE HELP thanks

  2. #2
    Join Date
    Jun 2005
    Location
    Georgia
    Posts
    155
    Piece of cake. I can write that in about ten minutes. I just need to know what is supposed to happen once the clock hits 2:00pm/12:00pm. Is some text supposed to display or something?

    I'm about to pack up my computer, but if you answer then I can have something posted later this evening...if no one else has posted anything, that is.

  3. #3
    Join Date
    Dec 2011
    Location
    Centurion, South Africa
    Posts
    795
    Here is my attempt, still personally interested to know how lonogod will do it:

    index.html
    Code:
    <!DOCTYPE html>
    <html lang="en">
    	<head>
    		<meta charset="utf-8" />
    		<title>Countdown</title>
    		<style type="text/css">
    
    			.CountDown {
    				border: 1px solid #000;
    				font-size: 2em;
    				text-align: center;
    			}
    
    		</style>
    		<script type="text/javascript">
    
    			window.onload = function()
    			{
    				var
    					text = document.getElementsByTagName('body')[0].appendChild(document.createElement('div')),
    					days = [
    						0,  //SUN
    						14, //MON
    						14, //TUE
    						14, //WED
    						14, //THU
    						12, //FRI
    						0   //SAT
    					];
    
    				text.className = 'CountDown';
    
    				setInterval(function()
    				{
    					var
    						date = new Date(), time, h, m, s, x;
    						time = Math.max(Math.floor(((new Date(date.getFullYear(), date.getMonth(), date.getDate(), days[date.getDay()], 0, 0).getTime()) - date.getTime()) / 1000), 0);
    
    					x = (time % 3600);
    					h = (time - x) / 3600;
    					s = (x % 60);
    					m = (x - s) / 60;
    
    					text.innerHTML = (h < 10 ? '0' : '') + h + ':' + (m < 10 ? '0' : '') + m + ':' + (s < 10 ? '0' : '') + s;
    
    				}, 1000);
    			};
    
    		</script>
    	</head>
    	<body>
    	</body>
    </html>
    Last edited by bionoid; 10-04-2013 at 06:41 PM. Reason: Relocated days array for single creation

  4. #4
    Join Date
    Jun 2005
    Location
    Georgia
    Posts
    155
    I'm sorry, just got home from a LOOOONG day. You still haven't responded though, so I guess it's not a big deal. I'm headed to bed but will try to get to it this weekend. Probably will have to wait until Monday when I'm back at work though. Even if someone else gives you exactly what you're looking for, I'll post mine just for the heck of it.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles