Activity › Forums › Adobe After Effects Expressions › Timer Days, Hours, Minutes, and Seconds
-
Timer Days, Hours, Minutes, and Seconds
Posted by Sarvar Alibekov on January 14, 2022 at 2:59 pmI want to create timer displays days hours minutes and seconds
Tomas Bumbulevičius replied 4 years, 3 months ago 3 Members · 2 Replies -
2 Replies
-
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 ; } nOn 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 ; } nMinutes, 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 ; } nAnd 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 ; } nThe 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)
Reply to this Discussion! Login or Sign Up