Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions FX Expression for Days Hours Min Sec Countdown?

  • Dan Ebberts

    November 13, 2016 at 5:48 am

    This should be close:


    function padZero(n){
    s = "" + n;
    if (s.length < 2) return ("0"+s);
    return s;
    }
    dayStart = 5;
    hrStart = 0;
    minStart = 0;
    secStart = 0;

    clockRate = 10;

    totalStartSec = ((dayStart*24 + hrStart)*60 + minStart)*60 + secStart;
    curTotalSec = totalStartSec - Math.round((time - inPoint)*clockRate);

    curDay = Math.floor(curTotalSec/(24*3600));
    curHr = Math.floor((curTotalSec%(24*3600))/3600);
    curMin = Math.floor((curTotalSec%3600)/60);
    curSec = curTotalSec%60;

    padZero(curDay) + " " + padZero(curHr) + " " + padZero(curMin) + " " + padZero(curSec)

    Dan

  • Sara Martinez

    November 15, 2016 at 2:39 am

    Thank you so much Dan!! You’re incredibly kind. This worked wonderfully. My only set back now is the rendering, but the script is exactly what I needed and it works great.

  • Elvis Muchara

    July 27, 2018 at 4:17 pm

    Hi, how can I change the time in this expression, say I want it to start at 05:10:15 and continue?

  • Dan Ebberts

    July 27, 2018 at 4:35 pm

    I’m not sure what you mean exactly, but maybe like this:


    function padZero(n){
    s = "" + n;
    if (s.length < 2) return ("0"+s);
    return s;
    }

    hrStart = 5;
    minStart = 10;
    secStart = 15;

    clockRate = 1;

    totalStartSec = ((hrStart)*60 + minStart)*60 + secStart;
    curTotalSec = totalStartSec - Math.floor((time - inPoint)*clockRate);

    curHr = Math.floor((curTotalSec%(24*3600))/3600);
    curMin = Math.floor((curTotalSec%3600)/60);
    curSec = curTotalSec%60;

    padZero(curHr) + ":" + padZero(curMin) + ":" + padZero(curSec)

    Dan

  • Salim Maurice

    July 3, 2020 at 6:12 pm

    Hi Dan,

    Thanks so much for this expression, I am trying to use it but I’d like to connect the trim path to your expression do you think this is possible?

    See screenshot

    Thanks very much in advance!!

  • Dan Ebberts

    July 3, 2020 at 11:54 pm

    I’m not sure what you’re after exactly, but this example would drive the Trim Paths End value from 100 to 0 as the seconds count down. Probably some form of this would do what you want:

    t = thisComp.layer(“time”).text.sourceText.value;
    sec = parseInt(t.split(” “)[3],10);
    linear(sec,0,60,0,100)

    Dan

  • Salim Maurice

    July 4, 2020 at 5:50 am

    Thanks for your fast feedback Dan! I dropped the expression but I am getting this error

    any idea why ?

    Thanks again for your time.

    Salim

  • Dan Ebberts

    July 4, 2020 at 6:27 am

    It might have to do with how you have the time formatted, but I can’t tell from your screenshot.

    Dan

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