View all expressions
Conditional

Days Until Date Counter

Dynamically calculates the remaining time until a specific target holiday or event. It compares the current time to the target and updates the text layer automatically, even detecting if the date has passed to reset for the next year.

Contributed by:


targetMonth = 12; // 1 = Jan, 12 = Dec
targetDay   = 31;
targetYear  = new Date().getFullYear();
today = new Date();
// Convert to JS month index (0–11)
jsMonth = targetMonth - 1;
targetDate = new Date(targetYear, jsMonth, targetDay);
// If date passed, count for next year
if (today > targetDate) {
targetDate = new Date(targetYear + 1, jsMonth, targetDay);
}
// Calculate difference in days
oneDay = 1000 * 60 * 60 * 24;
diff = targetDate.getTime() - today.getTime();
daysLeft = Math.ceil(diff / oneDay);
daysLeft + " Days Left";

Days Until Date Counter

Practical use case

Essential for creating "Countdown to Christmas" graphics, product launch timers, or event reminders in social media templates that need to remain accurate.

Check out similar expressions

Data-driven video workflows for After Effects are easier with Plainly.

a mesh of elegant lines transparent image