top of page

Digital Clock Expression

This After Effects expression creates a real-time digital clock by displaying the current time in a HH:MM:SS format.

Background Line UI

Dynamic, Clock, Time Based Animation

3.5K

// Get the current time in hours, minutes, and seconds
var t = time;  
var hours = Math.floor(t / 3600) % 24;  // Hours (24-hour format)
var minutes = Math.floor(t / 60) % 60;  // Minutes
var seconds = Math.floor(t) % 60;       // Seconds

// Format the time as HH:MM:SS
var formattedTime = pad(hours) + ":" + pad(minutes) + ":" + pad(seconds);
formattedTime;

// Function to add leading zero if number is less than 10
function pad(num) {
    return (num < 10) ? "0" + num : num;
}
For a composition starting at 0:00:00, after 5 minutes, the clock will display 00:05:00. After 1 hour, it will show 01:00:00. As the time continues, it will dynamically update, displaying 02:30:45 after 2 hours, 30 minutes, and 45 seconds. The clock will keep running and updating in real-time, formatted in HH:MM:SS, even if the composition is paused and played back later.
bottom of page