top of page
Countdown Expression
Clock, Dynamic, Time Based Animation
Countdown Expression
This After Effects expression creates a countdown timer that displays time in MM:SS format, counting down from a specified duration.
If you set the countdown time to `300` seconds (5 minutes), the timer will start at `05:00`. As the timer progresses, it will update to `04:59`, `04:58`, and so on. Once it reaches zero, it will display `00:00`. The countdown ensures a smooth, real-time display, even if the composition is paused and played back later.
// Set the countdown time in seconds
var countdownTime = 300; // Countdown from 5 minutes (300 seconds)
// Calculate the remaining time
var remainingTime = Math.max(countdownTime - time, 0); // Prevent negative time
// Convert remaining time to minutes and seconds
var minutes = Math.floor(remainingTime / 60);
var seconds = Math.floor(remainingTime % 60);
// Format the time as MM:SS
var formattedTime = pad(minutes) + ":" + pad(seconds);
formattedTime;
// Function to add leading zero for single-digit numbers
function pad(num) {
return (num < 10) ? "0" + num : num;
}
How to Use This Expression?
Create a Text Layer: Add a text layer to your composition.
Apply the Expression: Alt + Click (Windows) or Option + Click (Mac) the stopwatch icon for the Source Text property of the text layer.
Paste the script into the expression editor.
Adjust the Countdown Time: Modify
var countdownTime = 300;
to change the starting time (e.g.,60
for 1 minute,600
for 10 minutes).
Preview the Countdown: Play the composition to see the countdown timer in action.
Trending
bottom of page