Results 1 to 2 of 2

Thread: Javascript displaying incorrect date

  1. #1
    Join Date
    Dec 2005
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Javascript displaying incorrect date

    Hi, I need your help with a javascript that is incorrectly displaying the time left as 12 hours instead of 24 hours.

    The target date is July 7, 2010 at 09:00 AM
    Here is the url where the script is installed: http://guaranteedtransformation.com/independence/

    and here is the code:
    Code:
    <script LANGUAGE="JavaScript">
    // This following statement must be left intact.
    // Copyright (c) Michael Bloch and Taming The Beast.  
    // Countdown timer script v1.2 April 20 2009
    // Taming the Beast.net - http://www.tamingthebeast.net
    // Free Web Marketing and Ecommerce articles and tools
    // By using this code you agree to indemnify Taming the Beast
    // from from any liability that might arise from its use. 
    // The preceding statement be left intact. 
    
    
    var present;   
    var future;    
    var tseconds;  
    var seconds;   
    var minutes;
    var hours;
    var days;
    ID=setTimeout("countdown();", 1000);
    
    function countdown() 
    {
    present = new Date();
    present = present.getTime() + (60000) + (12 * 60 * 60 * 1000);
    future = new Date("July 07, 2010 09:00:00");
    
    tseconds = (future - present) / 1000;
    
    days = tseconds /24/60/60;
    days = Math.floor(days);
    tseconds = tseconds - (days * 24 * 60 * 60);
    
    hours = tseconds /60/60;
    hours = Math.floor(hours);
    tseconds = tseconds - (hours * 60 * 60);
    
    minutes = tseconds /60;
    minutes = Math.floor(minutes);
    tseconds = tseconds - (minutes * 60);
    
    seconds = tseconds;
    seconds = Math.floor(seconds);
    
    document.getElementById('days').innerHTML = days;
    document.getElementById('hours').innerHTML = hours;
    document.getElementById('minutes').innerHTML = minutes;
    document.getElementById('seconds').innerHTML = seconds;
    ID=setTimeout("countdown();", 1000);
    }
    </script>
    And here is the html that displays the time:
    Code:
    <SPAN id="days">0</SPAN>&nbsp;days,&nbsp;&nbsp;<SPAN id="hours">0</SPAN>&nbsp;hours,&nbsp; 
    <SPAN id="minutes">0</SPAN>&nbsp;minutes,&nbsp; 
    <SPAN id="seconds">0</SPAN>&nbsp;seconds&nbsp;
    Thanks for your help,
    Jimmy

  2. #2
    Join Date
    Dec 2005
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    It's solved. I've discovered a workaround that displays the proper time left.

Bookmarks

Posting Permissions

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