Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Creating a Ticking Down Timer

  • Creating a Ticking Down Timer

    Posted by Ben Kahane-rapport on February 1, 2014 at 5:49 am

    Hey Creative Cows,
    I’m trying to make a timer that ticks down from 97 years in real time. Ideally, it would be:
    years:months:days:hours:minutes:seconds
    Is this doable?

    The best I’ve got is the following, which has the first value going down every second, instead of the last:

    function decrementNumber(num, leading, modulus) {
    num=”” + Math.floor(num-((timefactor % 1) *num)) % modulus;
    while (num.length < leading) num=’0’+num;
    return num;

    }

    // Variables
    years=93;
    months=12;
    days=364;
    hours=24*days;
    minutes=60*hours;
    seconds=60*minutes;
    timefactor=time;

    // Calculations
    years=”” + Math.floor(years-timefactor);
    while (years.length < 2) years=’0′ + years;

    months=decrementNumber(months,2, 12 );
    days=decrementNumber(days,2, 28 );
    hours=decrementNumber(hours,2, 24 );
    minutes=decrementNumber(minutes,2, 60 );
    seconds=decrementNumber(minutes,2, 60 );

    counter=”” + years + “:” + months + “:” + days + “:” + hours + “:” + minutes +”:” + seconds

    Any help would be much appreciated! Thanks!

    Ben Kahane-rapport replied 12 years, 7 months ago 2 Members · 2 Replies
  • 2 Replies
  • Declan Smith

    February 1, 2014 at 11:43 am

    Hi Ben,

    I thought this looked familiar. My modified code is below which should meet your new requirement. This will start the counter at 97 years and count down in real time backwards. You can start the countdown by changing the variable ‘startDate’ .

    Hope this is what you are looking for:

    function pad(num, leading) {
    num=”” + num;
    while (num.length < leading) num=’0’+num;
    return num;
    }
    // Variables
    startDate = new Date(“01/01/2067 00:00″, ) ;

    date = new Date(startDate.getTime()-(time*1000));
    years=pad(date.getYear(date)-70,2);
    months=pad(date.getMonth()+1,2);
    days=pad(date.getDate(),2);
    hours=pad(date.getHours(),2);
    minutes=pad(date.getMinutes(),2);
    seconds=pad(date.getSeconds(),2);
    counter=”” + years + “:” + months + “:” + days + “:” + hours + “:” + minutes +”:” + seconds

    Declan Smith
    https://www.madpanic.tv
    After Effects CS6/ FCS3 / Canon XLH1 / Canon 7D / Reason / Cubase

    “it’s either binary or it’s not”

  • Ben Kahane-rapport

    February 1, 2014 at 9:29 pm

    Thank you so much! Your generosity is astounding 🙂

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy