how do i make a count down timer?

Discussion in 'JavaScript' started by Turpentine, Sep 16, 2006.

  1. #1
    I want to make a countdown timer to november 19 2006. I looked online and found a tutorial to do it in flash, but I just need some simple javascript.
    I want to put it on http://wiifantastic.com/index.php in the overview box.
     
    Turpentine, Sep 16, 2006 IP
  2. discoverclips

    discoverclips Peon

    Messages:
    491
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #2
    <script language="JavaScript">
    
    
    function show() {
    target = new Date("19 November, 2006"); 
    targetEpoch = target.getTime();
    today  = new Date();
    todayEpoch  = today.getTime();
    
    sLeft = Math.round((targetEpoch - todayEpoch)/1000);
    var id = document.getElementById("time");
    id.innerHTML = sLeft;
    setTimeout("show()",1000);
    }
    </script>
    <body onload="show()">
    <div id="time" style="border:1px solid blue; padding:4px;"></div>
    HTML:
    this gives the seconds left..
    you can format it to be days, hours, seconds, ...
     
    discoverclips, Sep 16, 2006 IP
  3. Turpentine

    Turpentine Guest

    Messages:
    219
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #3
    so how would i do days, hours, minutes, seconds?
     
    Turpentine, Sep 16, 2006 IP