www.webdeveloper.com
Results 1 to 2 of 2

Thread: Need help with count down timer for one full year

  1. #1
    Join Date
    Jan 2013
    Posts
    2

    Need help with count down timer for one full year

    I have been using this code below with great success , but sense I am a newbie with scripts, I am wondering how I could modify this script below to able to display a count down timer for one whole calender year, not to show all of them at once, but to show the next event count down when the other event has ended. Maybe like 2 days after the next event has ended to start the next count down timer to the next event coming up, Also is there a way you could make the title of an event to show up when the new timer is started?
    Code:
    ////////// CONFIGURE THE COUNTDOWN SCRIPT HERE //////////////////
    
    var month = '01';     //  '*' for next month, '0' for this month or 1 through 12 for the month 
    var day = '12';        //  Offset for day of month day or + day  
    var hour = 12;        //  0 through 23 for the hours of the day
    var tz = 0;          //  Offset for your timezone in hours from UTC
    var lab = 'tzcd';      //  The id of the page entry where the timezone countdown is to show
    
    function start() {displayTZCountDown(setTZCountDown(month,day,hour,tz),lab);}
    
        // **    The start function can be changed if required   **
    window.onload = start;
    
    ////////// DO NOT EDIT PAST THIS LINE //////////////////
    
    function setTZCountDown(month,day,hour,tz) 
    {
    var toDate = new Date();
    if (month == '*')toDate.setMonth(toDate.getMonth() + 1);
    else if (month > 0) 
    { 
    if (month <= toDate.getMonth())toDate.setYear(toDate.getYear() + 1);
    toDate.setMonth(month-1);
    }
    if (day.substr(0,1) == '+') 
    {var day1 = parseInt(day.substr(1));
    toDate.setDate(toDate.getDate()+day1);
    } 
    else{toDate.setDate(day);
    }
    toDate.setHours(hour);
    toDate.setMinutes(0-(tz*60));
    toDate.setSeconds(0);
    var fromDate = new Date();
    fromDate.setMinutes(fromDate.getMinutes() + fromDate.getTimezoneOffset());
    var diffDate = new Date(0);
    diffDate.setMilliseconds(toDate - fromDate);
    return Math.floor(diffDate.valueOf()/1000);
    }
    function displayTZCountDown(countdown,tzcd) 
    {
    if (countdown < 0) document.getElementById(tzcd).innerHTML = "The Event has started or over"; 
    else {var secs = countdown % 60; 
    if (secs < 10) secs = '0'+secs;
    var countdown1 = (countdown - secs) / 60;
    var mins = countdown1 % 60; 
    if (mins < 10) mins = '0'+mins;
    countdown1 = (countdown1 - mins) / 60;
    var hours = countdown1 % 24;
    var days = (countdown1 - hours) / 24;
    document.getElementById(tzcd).innerHTML = days + " day" + (days == 1 ? '' : 's') + ' + ' +hours+ 'h : ' +mins+ 'm : '+secs+'s';
    setTimeout('displayTZCountDown('+(countdown-1)+',\''+tzcd+'\');',999);
    }
    }

  2. #2
    Join Date
    Jan 2013
    Posts
    2

    bump

    bump

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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