Forums › Adobe After Effects Expressions › Timer Days, Hours, Minutes, and Seconds
-
Timer Days, Hours, Minutes, and Seconds
Tomas Bumbulevičius updated 6 months, 2 weeks ago 3 Members · 3 Posts
-
Sarvar Alibekov
January 14, 2022 at 2:59 pmI want to create timer displays days hours minutes and seconds
-
Kevin Camp
January 14, 2022 at 6:53 pmThis 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 pmOnce you find this, you won’t be able to unseen it 🙂 Just make sure to set expressions language to Javascript (not a legacy one)
Viewing 1 - 3 of 3 posts
Log in to reply.