Skip to content

Instantly share code, notes, and snippets.

@maximilliangeorge
Last active April 9, 2020 15:05
Show Gist options
  • Save maximilliangeorge/a0ba19223c1fca8ee8692d6263d4153a to your computer and use it in GitHub Desktop.
Save maximilliangeorge/a0ba19223c1fca8ee8692d6263d4153a to your computer and use it in GitHub Desktop.
AE Countdown
// COUNTDOWN
//
// Creates a countdown in the following format:
// 00D:00H:00M:00S
//
// 1. Create text layer
// 2. Apply expression to text property.
rate = -1;
clockStart = 930604.999;
function padZero(n){
return (n < 10 ? "0" : "") + n;
}
clockTime = clockStart + rate*(time - inPoint);
if (clockTime < 0){
sign = "-";
clockTime = -clockTime;
}else{
sign = "";
}
t = Math.floor(clockTime);
d = Math.floor(t/(3600*12));
hr = Math.floor(t/3600);
min = Math.floor((t%3600)/60);
sec = Math.floor(t%60);
ms = clockTime.toFixed(2).substr(-2);
sign + padZero(d) + ":" + padZero(hr) + ":" + padZero(min) + ":" + padZero(sec) + ":" + ms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment