Countdown Clock Help?

Hey guys,

I’m looking to have a countdown clock on my website that will countdown to 12:00pm server time everyday. So once 0 is reached the clock will begin counting down to the new days 12:00pm.

I would like this to be an actual countdown so probably php + javascript?

If anybody could point me in the right direction on where I may be able to find a script that I might be able to modify to achieve what I’m looking for I would greatly appreciate it.

Thanks for looking,
Mario

Yes, the PHP bit simply tells the JavaScript what the current server time is. The JavaScript would be the workhorse of this, taking the server time, working out what to display and updating the value every second or minute. It’s pretty easy to do - I suggest you start off looking at the Date functions of JavaScript. You might want the PHP to supply the server time as a timestamp, which JavaScript is able to work with (milliseconds in the reference linked to).

Thank you for the start Raffles.

I have managed to find a javascript countdown and figured out how to get the time I’m looking for in PHP.

But I’ve run into a barrier now. How can I combine the 2 to work together. And how can I go about it resetting and not jyst stopping once it reaches 0?

The uploaded code can be found here: http://www.rainisfree.com/


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Untitled Document</title>
        <?PHP
        
		$today = date("H:i:s");
		echo $today;
		
		?>
        <SCRIPT LANGUAGE="JavaScript">
            <!--
            
            var eventdate = new Date("January 22, 2010 12:00:00");
            
            function toSt(n) {
            s=""
            if(n<10) s+="0"
            return s+n.toString();
            }
            
            function countdown() {
            cl=document.clock;
            d=new Date();
            count=Math.floor((eventdate.getTime()-d.getTime())/1000);
            if(count<=0)
            {cl.days.value ="----";
            cl.hours.value="--";
            cl.mins.value="--";
            cl.secs.value="--";
            return;
            }
            cl.secs.value=toSt(count%60);
            count=Math.floor(count/60);
            cl.mins.value=toSt(count%60);
            count=Math.floor(count/60);
            cl.hours.value=toSt(count%24);
            count=Math.floor(count/24);
            cl.days.value=count;
            
            setTimeout("countdown()",500);
            }
			
            // end hiding script-->
        </SCRIPT>
    </head>
    <body onLoad="countdown()">
        <FORM name="clock">
            <TABLE BORDER=5 CELLSPACING=5 CELLPADDING=0 BGCOLOR="#000000">
                <TR>
                    <TD ALIGN=CENTER><INPUT name="days" size=2></TD>
                    <TD ALIGN=CENTER><INPUT name="hours" size=2></TD>
                    <TD ALIGN=CENTER><INPUT name="mins" size=2></TD>
                    <TD ALIGN=CENTER><INPUT name="secs" size=2></TD>
                </TR>
            </TABLE>
        </FORM>
    </body>
</html>

Any help would be appreciated.

Thanks,
Mario