Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Expressions Timer Days, Hours, Minutes, and Seconds

  • Timer Days, Hours, Minutes, and Seconds

  • Sarvar Alibekov

    January 14, 2022 at 2:59 pm

    I want to create timer displays days hours minutes and seconds

  • Kevin Camp

    January 14, 2022 at 6:53 pm

    This might work for you.

    Create 4 text layers and name them ‘Days’, ‘Hours’, ‘Minutes’, ‘Seconds’. Then add a slider expression control to the Days text layer and set key frames to have the slider count down from 10 to 0 (or however you want it).

    On the Days text layer, add this expression to the Source Text:

    days = Math.floor( effect("Slider Control")("Slider") ) ;
    n = days.toString() ;
    if ( n.length == 1 ) { n = '0' + n ; }
    n

    On the Hours text layer add this expression:

    days = thisComp.layer("Days").effect("Slider Control")("Slider") ;
    hrs = Math.floor( ( days % 1 ) * 24 )
    n = hrs.toString() ;
    if ( n.length == 1 ) { n = '0' + n ; }
    n

    Minutes, add this expression:

    days = thisComp.layer("Days").effect("Slider Control")("Slider") ;
    mins = Math.floor( ( ( ( days % 1 ) * 24 ) % 1 ) * 60 ) ;
    n = mins.toString() ;
    if ( n.length == 1 ) { n = '0' + n ; }
    n

    And Seconds, add this expression:

    days = thisComp.layer("Days").effect("Slider Control")("Slider") ;
    secs = Math.floor( ( ( ( ( ( days % 1 ) * 24 ) % 1 ) * 60 ) % 1 ) * 60 )
    n = secs.toString() ;
    if ( n.length == 1 ) { n = '0' + n ; }
    n

    The text in the layers should now count down.

  • Tomas Bumbulevičius

    January 24, 2022 at 6:16 pm

    Once you find this, you won’t be able to unseen it 🙂 Just make sure to set expressions language to Javascript (not a legacy one)

    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat

Viewing 1 - 3 of 3 posts

Log in to reply.

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