• | **5 Minute Countdown**
on Jul 21, 2008 at 8:36:03 pm |

I'm trying to make a countdown which counts down from 5:00 Minutes to 0:00.

I want it to work in actual seconds, like a normal clock.

I've tryed Effect/Text/Numbers.

I've messed with all the things for weeks and can't figure it out.

Searched the internet and still can't find what i need.

Can anyone help me?

Tutorial? Anything?

Thanks,

Stephen

• | **Re: 5 Minute Countdown** on Jul 21, 2008 at 9:26:41 pm |

Try pasting this into the source text property of a text layer:

rate = -1;

clockStart = 300;

function padZero(n){

if (n < 10) return "0" + n else return "" + n

}

clockTime = Math.max(clockStart + rate*(time - inPoint),0);

t = Math.floor(clockTime);

min = Math.floor((t%3600)/60);

sec = Math.floor(t%60);

min + ":" + padZero(sec)

Dan

• | **Re: 5 Minute Countdown** on Jul 22, 2008 at 12:08:18 am |

What about for a 2 minute one?

WHat would i change?

that one worked great! THANKS!

• | **Re: 5 Minute Countdown** on Jul 22, 2008 at 12:29:19 am |

Just change the 300 to 120 (the duration is in seconds).

Dan

• | **Re: 5 Minute Countdown** on Jul 22, 2008 at 4:56:51 am |

Thanks Dan.

You've been incredibly helpful.

Exactly what i needed to know!!

You Rock!

• | **Re: 5 Minute Countdown** on Aug 2, 2008 at 4:54:48 pm |

I've been trying to get this expression to show milliseconds and I just can't get it to work. I've tried some other expressions that do it, but they all seem to break. I have to create a 45min 30sec countdown, but I want it to show milliseconds as well.

Please help

Thanks,

Kjell

• | **Re: 5 Minute Countdown** on Aug 2, 2008 at 5:28:41 pm |

Try this:

rate = -1;

clockStart = 2730;

function padZero(n){

if (n < 10) return "0" + n else return "" + n

}

clockTime = clockStart + rate*(time - inPoint);

if (clockTime < 0){

sign = "-";

clockTime = -clockTime;

}else{

sign = "";

}

t = Math.floor(clockTime);

min = Math.floor((t%3600)/60);

sec = Math.floor(t%60);

ms = clockTime.toFixed(3).substr(-3);

sign + padZero(min) + ":" + padZero(sec) + "." + ms

Dan

• | **Re: 5 Minute Countdown** on Jan 20, 2009 at 7:36:18 pm |

Hi Dan,

Great post. I tried it out and perfect. The only problem is that is doesn't work for what I need and I can't figure out what to change.

I need a clock that counts up normally that shows hr:min:sec starting at whatever time.

Is there a simple fix to make this work?

• | **Re: 5 Minute Countdown** on Jan 20, 2009 at 9:00:19 pm |

This source text expression should work. Just set the clockStart variable to the start time (in seconds).

rate = 1;

clockStart = 0;

function padZero(n){

if (n < 10) return "0" + n else return "" + n

}

clockTime = clockStart + rate*(time - inPoint);

if (clockTime < 0){

sign = "-";

clockTime = -clockTime;

}else{

sign = "";

}

t = Math.floor(clockTime);

hr = Math.floor(t/3600);

min = Math.floor((t%3600)/60);

sec = Math.floor(t%60);

sign + padZero(hr) + ":" + padZero(min) + ":" + padZero(sec)

Dan

• | **Re: 5 Minute Countdown** on Jan 21, 2009 at 4:53:27 pm |

Thanks for your help Dan but before I read your post I stumbled across this one

addedSec = thisComp.layer("Controller").effect("Seconds")("Slider");

addedMin = thisComp.layer("Controller").effect("Minutes")("Slider")*60;

addedHr = thisComp.layer("Controller").effect("Hours")("Slider")*3600;

addedTime = addedSec + addedMin + addedHr;

sec = Math.floor(time + addedTime) * thisComp.layer("Controller").effect("Time Multiplier")("Slider");

minvar = Math.floor(sec/60);

hrvar = Math.floor(sec/3600);

sechrvar = Math.floor(sec - (3600*hrvar));

minhrvar = Math.floor(sechrvar/60);

if(sec<0){

"Err: Negative Time"

}else{

if ((sec - 10) < 0) {

":0" + sec

} else {

if ((sec - 60) < 0) {

":" + sec

}else{

if (((sec/60)>1) && ((sec - minvar*60)<10) && (sec<3600)) {

(minvar) + ":0" + (sec - minvar*60)

}else{

if ((sec - 60) < 0) {

":" + sec

}else{

if ((sec/60) == 1) {

(minvar) + ":00"

}else{

if (((sec/60)>1) && ((sec - minvar*60)>=10) && (sec<3600)) {

(minvar) + ":" + (sec - minvar*60)

}else{

if((sec - 3600*hrvar) == 0){

(hrvar) + ":00:00"

}else{

if(((sec - 3600) > 0) && ((sec - (3600*hrvar) - (minhrvar*60)< 10)) && (minhrvar<10)){

(hrvar) + ":0" + minhrvar + ":0" + (sechrvar - minhrvar*60)

}else{

if(((sec - 3600) > 0) && ((sec - (3600*hrvar) - (minhrvar*60)) >=10) && (minhrvar < 10)){

(hrvar) + ":0" + minhrvar + ":" + (sechrvar - minhrvar*60)

}else{

if(((sec - 3600) > 0) && ((sec - (3600*hrvar) - (minhrvar*60)) < 10) && (minhrvar >= 10)){

(hrvar) + ":" + minhrvar + ":0" + (sechrvar - minhrvar*60)

}else{

if(((sec - 3600) > 0) && ((sec - (3600*hrvar) - (minhrvar*60)) >=10) && (minhrvar >= 10)){

(hrvar) + ":" + minhrvar + ":" + (sechrvar - minhrvar*60)

}else{

sec}}}}}}}}}}}}

I can't remember if you had written it on another forum but it worked great.

But once again thank you for your help either way. It's great to know that there are people out there always willing to help.

Cheers

• | **Re: 5 Minute Countdown** on Oct 8, 2009 at 4:50:29 pm |

This is exactly what I need but unfortunatelly when I paste it in expressions place it said that there is a mistake on line 6 and the expression is disabled

• | **Re: 5 Minute Countdown** on Oct 8, 2009 at 5:40:44 pm |

Which property did you paste it into, and what was the exact error message?

Dan

• | **Re: 5 Minute Countdown** on Jan 20, 2010 at 5:30:49 pm |

I'm having the same issue with an error on line six. Did anyone ever find out what the problem was?

• | **Re: 5 Minute Countdown** on Jun 9, 2011 at 3:04:52 pm |

I am getting the Line 6 error as well.

After Effects warning: Expected: )

Expression disabled

Error occurred at Line 6.

Comp: 'Comp 2'

Layer: 1 ('5:00')

Proprty: 'Positon'

Obviously its looking to close a parentheses somewhere?

line 6 should correspond to the if statement and the "n" var opens but does not close?

using this code:

`rate = -1;`

clockStart = 300;

function padZero(n){

if (n

}

clockTime = Math.max(clockStart + rate*(time - inPoint),0);

t = Math.floor(clockTime);

min = Math.floor((t%3600)/60);

sec = Math.floor(t%60);

min + ":" + padZero(sec)

• | **Re: 5 Minute Countdown** on Jun 9, 2011 at 3:36:15 pm |

Somewhere along the line the padZero function got messed up, probably because of the "<".

It should look like this:

function padZero(n){

if (n < 10) return "0" + n else return "" + n;

}

Dan

• | **Re: 5 Minute Countdown** on Jun 10, 2011 at 5:02:56 pm |

thanks that helped!

• | **Re: 5 Minute Countdown** on Nov 7, 2011 at 11:26:46 pm |

Bonsoir,

Merci pour ton aide tout d'abord. After Effects est loin d'être facile à prendre en main. Et c'est bien la première fois que je vois un logiciel comme celui-ci qui demande de savoir programmer!

Bref, j'aurais besoin à nouveau de tes lumières...

Cette expression ci dessous marche très bien mais j'aimerais rajouter les millisecondes dans le décompte, histoire d'avoir un truc un peu plus dynamique.

Tu crois que tu pourrais me filer un coup de pouce?

Merci d'avance!

Bonne nuit

`rate = -1;`

clockStart = 1440;

function padZero(n){

if (n < 10) return "0" + n else return "" + n;

}

clockTime = Math.max(clockStart + rate*(time - inPoint),0);

t = Math.floor(clockTime);

min = Math.floor((t%3600)/60);

sec = Math.floor(t%60);

mil = Math.floor(t%500)

min + ":" + padZero(sec)

• | **Re: 5 Minute Countdown** on Nov 7, 2011 at 11:53:58 pm |

S'il vous plaît, essayez ceci:

rate = -1;

clockStart = 1440;

function padZero(n){

return ((n < 10) ? "0" : "") + n

}

clockTime = Math.max(clockStart + rate*(time - inPoint),0);

t = Math.floor(clockTime);

min = Math.floor((t%3600)/60);

sec = Math.floor(t%60);

min + ":" + padZero(sec) + clockTime.toFixed(3).substr(-4)

Dan

• | **Re: 5 Minute Countdown** on Nov 8, 2011 at 9:16:37 pm |

Thank you for your help.

But i've done a mistake. I need tenth second, not thousandth second.

And there is an another problem on the digital display. There is only "on point" between the second and the thousandth second but we need two points like what we have between minute and second.

Could you help for that?

Thank you.

PS : Sorry for my english, i m a little bit rusty...

• | **Re: 5 Minute Countdown** on Nov 8, 2011 at 11:58:23 pm |

Try this:

rate = -1;

clockStart = 1440;

function padZero(n){

return ((n < 10) ? "0" : "") + n;

}

clockTime = Math.max(clockStart + rate*(time - inPoint),0);

t = Math.floor(clockTime);

min = Math.floor((t%3600)/60);

sec = Math.floor(t%60);

min + ":" + padZero(sec) + ":" + clockTime.toFixed(1).substr(-1)

Dan

• | **Re: 5 Minute Countdown** on Nov 9, 2011 at 12:22:33 am |

It's perfect but do you know how i could save correctly this composition to read it on quicktime or VLC?

As soon as i want to save it, the final composition run during 30 sec and stop itself. It doesn t make sense, the countdown last 24 minutes. Any solution?

Thank you!

• | **Re: 5 Minute Countdown** on Nov 9, 2011 at 3:12:39 am |

If your comp is long enough, it should count down the whole 24 minutes. Are you possibly looking at a preview? You'll need to render a movie to see the whole thing: Composition > Make Movie...

Sorry if you already knew that.

Dan

• | **Re: 5 Minute Countdown** on Nov 9, 2011 at 7:47:39 pm |

The countdown only to last 30 sec. I don t know how make it run 24 minutes...

After 23:30:04, it stop. That's weird, isn'it?

• | **Re: 5 Minute Countdown** on Nov 9, 2011 at 7:51:46 pm |

Seems weird to me.

Dan

• | **Re: 5 Minute Countdown** on Nov 9, 2011 at 8:00:52 pm |

Could i send you the file to take a quick look on it?

• | **Re: 5 Minute Countdown** on Nov 9, 2011 at 8:10:00 pm |

Sure. You can contact me through my web site:

http://www.motionscript.com
Dan

• | **Re: 5 Minute Countdown** on May 24, 2012 at 6:42:52 pm |

is not posible to pause the time and resume it? will be great if is possible to add some kind of key into the timeline to pause and again resume it.

• | **Re: 5 Minute Countdown** on May 24, 2012 at 8:34:37 pm |

I can use this expression with any frame rate like 24-29-60 or the code just follow the comp frame rate by itself?

Thanks.

`rate = -1;`

clockStart = 300;

function padZero(n){

if (n < 10) return "0" + n else return "" + n

}

clockTime = Math.max(clockStart + rate*(time - inPoint),0);

t = Math.floor(clockTime);

min = Math.floor((t%3600)/60);

sec = Math.floor(t%60);

min + ":" + padZero(sec)

• | **Re: 5 Minute Countdown** on May 24, 2012 at 9:01:54 pm |

You set the countdown rate in the first line. At -1 it counts at regular comp speed, at -2 it would be twice as fast, etc. Does that answer your question?

Dan

• | **Re: 5 Minute Countdown** on May 24, 2012 at 10:53:34 pm |

I think i got it.

If i keep -1 the expression will work as the same a comp frame rate is.

I have another question wich is the same one above of Jose.

Using this expression to a "fight" scene where the judge sometimes stop and the counter must stop to then when he start will continue the same time position.

Is possible to add somes keys into the timeline to pause and resume?

Ex:

5:00 ~ 4:10 run

4:10~3:40 stop

3:40~2:20 run

2:20~1:30 stop

1:30~0:00 run

Regards.

Jun

`rate = -1; clockStart = 300; function padZero(n){ if (n < 10) return "0" + n else return "" + n } clockTime = Math.max(clockStart + rate*(time - inPoint),0); t = Math.floor(clockTime); min = Math.floor((t%3600)/60); sec = Math.floor(t%60); min + ":" + padZero(sec)`

• | **Re: 5 Minute Countdown** on May 25, 2012 at 1:08:26 am |

You would need a more complex expression. Here's one that uses a checkbox control on the text layer to drive the count down. The count only proceeds when the checkbox is in the "on" state.

p = effect("Checkbox Control")("Checkbox");

accum = 0;

ct = inPoint;

cv = p.valueAtTime(inPoint);

for (i = 1; i <= p.numKeys; i++){

kt = p.key(i).time;

if (kt <= inPoint) continue;

if (kt >= time) break;

accum += cv*(kt - ct);

cv = p.key(i).value;

ct = kt;

}

accum += cv*(time-ct);

rate = -1;

clockStart = 1440;

function padZero(n){

return ((n < 10) ? "0" : "") + n;

}

clockTime = Math.max(clockStart + rate*accum,0);

t = Math.floor(clockTime);

min = Math.floor((t%3600)/60);

sec = Math.floor(t%60); min + ":" + padZero(sec) + ":" + Math.floor((clockTime%1)*10)

Dan

• | **Re: 5 Minute Countdown** on May 25, 2012 at 3:03:48 am |

Wow...

Just wonderfull!!

Thank you!!

"Arigatou Gozaimashita!!"

Jun

• | **Re: 5 Minute Countdown** on Nov 9, 2011 at 7:54:12 pm |

In fact, the countdown restart from the beginning... It run from 24:00:00 to 23:30:04 and restart from 24:00:00 after 30 sec...

I need a really countdown of 24minutes and not 30 sec +S

Please, help!

• | **Re: 5 Minute Countdown** on Sep 25, 2017 at 10:50:25 am |

Hi Dan.

Is it posible to remove proportional spacing, so that numbers stay in their places as the time is going on?

• | **Re: 5 Minute Countdown** on Jan 31, 2009 at 2:00:05 pm |

Great one Dan, thx

Is there a way to have this countdown display in absolute seconds (300, 299, 298...) rather then in a clock format (5:00, 4:59..)?

• | **Re: 5 Minute Countdown** on Jan 31, 2009 at 9:05:50 pm |

Try this:

rate = -1;

clockStart = 300;

clockTime = Math.max(clockStart + rate*(time - inPoint),0);

Math.ceil(clockTime)

Dan

• | **Re: 5 Minute Countdown** on Feb 6, 2009 at 7:07:56 pm |

This is great. Thanks for doing this.

I am curious if there is a way to change the font type of the numbers using this method.

• | **Re: 5 Minute Countdown** on Feb 6, 2009 at 8:23:59 pm |

No, expression don't have access to font info.

Dan

• | **Re: 5 Minute Countdown** on Nov 30, 2009 at 10:29:59 pm |

hi,

I tried using this code but it seems its limited to an hour. i am trying to do a 2 hour countdown. is there something else i need to change besides the seconds?

-mike

• | **Re: 5 Minute Countdown** on Nov 30, 2009 at 11:14:27 pm |

There's a lot of code in this thread. To which are you refering?

Dan

• | **Re: 5 Minute Countdown** on Nov 30, 2009 at 11:17:23 pm |

this one

`rate = -1; `

clockStart = 300;

function padZero(n){

if (n < 10) return "0" + n else return "" + n

}

clockTime = Math.max(clockStart + rate*(time - inPoint),0);

t = Math.floor(clockTime);

min = Math.floor((t%3600)/60);

sec = Math.floor(t%60);

min + ":" + padZero(sec)

• | **Re: 5 Minute Countdown** on Nov 30, 2009 at 11:31:07 pm |

Play around with this one:

rate = -1;

clockStart = 7200;

function padZero(n){

if (n < 10) return "0" + n else return "" + n

}

clockTime = Math.max(clockStart + rate*(time - inPoint),0);

t = Math.ceil(clockTime);

hr = Math.floor(t/3600);

min = Math.floor((t%3600)/60);

sec = Math.floor(t%60);

padZero(hr) + ":" + padZero(min) + ":" + padZero(sec)

Dan

• | **Re: 5 Minute Countdown** on Jan 26, 2010 at 8:25:57 am |

Hi,

First of all thank you very much Dan for this thread it's really very helpful for the expression dummies like me. :)

I am doing a countdown for 5:00 and am having an error message on line 6 like 2 other people.

I am using your first expression: (on a text layer on which i wrote 5:00)

rate = -1;

clockStart = 300;

function padZero(n){

if (n < 10) return "0" + n else return "" + n

}

clockTime = Math.max(clockStart + rate*(time - inPoint),0);

t = Math.floor(clockTime);

min = Math.floor((t%3600)/60);

sec = Math.floor(t%60);

min + ":" + padZero(sec)

I can't see what the problem is.

rate = -1;

clockStart = 300;

function padZero(n){

if (n < 10) return "0" + n else return "" + n

}

clockTime = Math.max(clockStart + rate*(time - inPoint),0);

t = Math.floor(clockTime);

min = Math.floor((t%3600)/60);

sec = Math.floor(t%60);

min + ":" + padZero(sec)

• | **Re: 5 Minute Countdown** on Nov 26, 2010 at 3:44:13 am |

Hi Dan,

Thank you for these script tips.

One problem I'm come across is the countdown eventually falling out of synch; apparently due to the 23.976 frame rate -- it works like a charm at 24 fps.

Any help would be greatly appreciated.

Thank you for your time.

Cheers.

S.J.

`rate = -1; `

clockStart = 3600;

function padZero(n){

if (n < 10) return "0" + n else return "" + n

}

clockTime = Math.max(clockStart + rate*(time - inPoint),0);

t = Math.floor(clockTime);

min = Math.floor((t%3601)/60);

sec = Math.floor(t%60);

padZero(min) + ":" + padZero(sec)

• | **Re: 5 Minute Countdown** on Aug 28, 2012 at 10:05:56 pm |

Hi code works great but I am wondering if their is away to get rid of the leading number when they turn to zero.

Chad

• | **Re: 5 Minute Countdown** on Aug 28, 2012 at 10:16:41 pm |

I'm not sure which version you're talking about, but to eliminate leading zeros you would eliminate the call to padZero():

rate = -1;

clockStart = 7200;

function padZero(n){

if (n < 10) return "0" + n else return "" + n

}

clockTime = Math.max(clockStart + rate*(time - inPoint),0);

t = Math.ceil(clockTime);

hr = Math.floor(t/3600);

min = Math.floor((t%3600)/60);

sec = Math.floor(t%60);

"" + hr + ":" + min + ":" + padZero(sec)

Dan

• | **Re: 5 Minute Countdown** on Aug 29, 2012 at 12:46:02 am |

Hi Dan I am confused. Here is the code I am using. I want I five minute countdown. But when it gets down to just seconds I dont want the zeros to shows.

rate = -1;

clockStart = 300;

function padZero(n){

if (n < 10) return "0" + n else return "" + n

}

clockTime = Math.max(clockStart + rate*(time - inPoint),0);

t = Math.floor(clockTime);

min = Math.floor((t%3600)/60);

sec = Math.floor(t%60);

min + ":" + padZero(sec)

Chad

• | **Re: 5 Minute Countdown** on Aug 29, 2012 at 2:08:16 am |

I'm still not sure exactly what you're after, but try changing the last line to this:

(min > 0 ? min : "") + ":" + padZero(sec)

and if that's not it, try this:

min > 0 ? min + ":" + padZero(sec) : sec

Dan

• | **Re: 5 Minute Countdown** on Aug 29, 2012 at 4:04:50 am |

That a little closer. What I want it to do is somthing like this count down from 5:00, 5:59,5:58.....4:00...3:00...1:00, 59, 58 ...10, 9, 8, 7 ... 1, 0

Sorry for all the confusion

Chad

• | **Re: 5 Minute Countdown** on Aug 29, 2012 at 4:27:02 am |

Now I'm confused. Isn't that what the second variation from my previous post does?

Dan

• | **Re: 5 Minute Countdown** on Aug 29, 2012 at 12:07:19 pm |

The last post does do that except when it gets down to sec the semi colon is still showing. The previous one were I get ride of the call to padZero does count down in sec but does not show the minutes.

Thanks for all the help.

Chad

• | **Re: 5 Minute Countdown** on Jun 16, 2015 at 11:14:31 am |

Hi Dan,

That script was very helpful.... Is there any way in the script that I can start the countdown after couple of seconds....

`rate = -1;`

clockStart = 300;

function padZero(n){

if (n < 10) return "0" + n else return "" + n

}

clockTime = Math.max(clockStart + rate*(time - inPoint),0);

t = Math.floor(clockTime);

min = Math.floor((t%3600)/60);

sec = Math.floor(t%60);

min + ":" + padZero(sec)

• | **Re: 5 Minute Countdown** on Jun 16, 2015 at 7:56:27 pm |

This gives a two-second delay:

rate = -1;

clockStart = 300;

delay = 2;

function padZero(n){

if (n < 10) return "0" + n else return "" + n

}

t = Math.max(time - delay,0);

clockTime = Math.max(clockStart + rate*(t - inPoint),0);

t = Math.floor(clockTime);

min = Math.floor((t%3600)/60);

sec = Math.floor(t%60);

min + ":" + padZero(sec)

Dan

• | **Re: 5 Minute Countdown** on Jun 16, 2015 at 8:22:45 pm |

Thanks Dan,

That worked :)

• | **Re: 5 Minute Countdown** on Mar 11, 2016 at 9:34:21 pm |

Dan,

I want to start off by saying thank you for all the work you do answering question on these forums.

I've been using this countdown expression for some time now, but in a 10 minute interval. Without fail, the countdown always displays time "4:04" (four minutes and four seconds) as "5:14" (five minutes and fourteen seconds). I've tried change the delay to 0, 1, etc... but no matter what 4:04 always is replaced with 5:14.

Thoughts on why this happens and possibly a solution for the issue?

Here is a video showing my issue.

9880_countdownvideo.mov.zip
`rate = -1;`

clockStart = 600;

delay = 2;

function padZero(n){

if (n < 10) return "0" + n else return "" + n

}

t = Math.max(time - delay,0);

clockTime = Math.max(clockStart + rate*(t - inPoint),0);

t = Math.floor(clockTime);

min = Math.floor((t%3600)/60);

sec = Math.floor(t%60);

min + ":" + padZero(sec)

• | **Re: 5 Minute Countdown** on Mar 12, 2016 at 7:40:27 pm |

That's fascinating. I can create the same result, although sometimes it's the reverse (4:04 where 5:14 should be). It seems like it might be a caching issue of some kind where the two results are seen as equivalent (= already rendered) by the caching system. That's just speculation though.

Dan

• | **Re: 5 Minute Countdown** on Mar 13, 2016 at 2:24:31 am |

Dan, thanks for the quick reply. I believe you are correct about the cache issue. I just changed the opacity of that 1 second to 99% and it seems to render those frames fresh instead of pulling them from the cache. The time is correct when opacity is set to 99%.

• | **Re: 5 Minute Countdown** on Oct 29, 2015 at 10:16:45 pm |

Dan,

The countdown/up script on your website is super helpful and very customizable so thank you for that genius piece of code.

I noticed that the counter seems to round in the wrong direction when counting. Here's an example of it counting down: 59.02, 59.01, 58.00, 58.99, 58.98

Is there a simple code solution related to the padding that I can use for this?

Thanks!

-Adam Fram

adamfram.com

`rate = -1;`

clockStart = 600.00;

function padZero(n){

if (n < 10) return "0" + n else return "" + n

}

clockTime = clockStart + rate*(time - inPoint);

if (clockTime < 0){

sign = "-";

clockTime = -clockTime;

}else{

sign = "";

}

t = Math.floor(clockTime);

hr = Math.floor(t/3600);

min = Math.floor((t%3600)/60);

sec = Math.floor(t%60);

ms = clockTime.toFixed(2).substr(-2);

padZero(min) + ":" + padZero(sec) + "." + ms

• | **Re: 5 Minute Countdown** on Oct 30, 2015 at 2:51:43 am |

This should work better:

rate = -1;

clockStart = 600.00;

function padZero(n){

if (n < 10) return "0" + n else return "" + n

}

clockTime = clockStart + rate*(time - inPoint);

t = clockTime.toFixed(2);

ms = t.substr(-2);

t = parseInt(t,10);

min = Math.floor((t%3600)/60);

sec = Math.floor(t%60);

padZero(min) + ":" + padZero(sec) + "." + ms

Dan

• | **Re: 5 Minute Countdown** on Oct 30, 2015 at 5:30:15 pm |

Perfect. Thanks Dan, you rock!

--

Adam Fram

adamfram.com

• | **Re: 5 Minute Countdown** on Feb 19, 2016 at 7:48:10 am |

Thanks- this was a huge help!

• | **Re: 5 Minute Countdown** on Feb 23, 2016 at 4:00:07 pm |

How can you get this Expression to ease out (decay)? I've tried inputting *Math.exp(decay*t) * but I can't get the count up to slow down at the end.

`numDecimals = 0;`

commas = false;

dollarSign = false;

beginCount = 0;

endCount = 672;

dur = 2;

dec = .5;

t = time - inPoint;

s = linear (t , 0, dur, beginCount, endCount).toFixed(numDecimals);

prefix = "";

if (s[0] == "-"){

prefix = "-";

s = s.substr(1);

}

if(dollarSign) prefix += "$";

if (commas){

decimals = "";

if (numDecimals > 0){

decimals = s.substr(-(numDecimals + 1));

s = s.substr(0,s.length - (numDecimals + 1));

}

outStr = s.substr(-s.length, (s.length-1)%3 +1);

for (i = Math.floor((s.length-1)/3); i > 0; i--){

outStr += "," + s.substr(-i*3,3);

}

prefix + outStr + decimals;

}else{

prefix + s ;

}

• | **Re: 5 Minute Countdown** on Nov 27, 2018 at 3:01:44 pm |

Don't you know, if it's possible to automatically get Clockstart (e.g. composition length in frames) I dig through a google but found nothing...

• | **Re: 5 Minute Countdown** on Dec 17, 2016 at 10:47:20 am |

If you are tired of expressions, you can use our cool Time Preset so you can animate Digital Clocks and Timers, easily and with no coding, cheers!

http://www.vdodna.com/products/digital-clock-timer-presets/