<p>The Timecode effect (effects>text>timecode) will add a timecode, but it's measured in HH:MM:SS:FF rather than milliseconds. </p>

<p>You could do it with an expression by adding a text layer, and applying an expression to the <strong>Source Text</strong> property. Below is an expression that returns what you want.</p>

<p>To apply it, alt-click on the stop watch for the text layers <strong>Source Text</strong> property and paste the expression in.</p>

<p><img src="https://i.sstatic.net/g2Kp6.png" alt="alt click the stopwatch"></p>

<p>This expression includes an offset, because the <strong>time</strong> constant in AE starts at 0, no matter what your comp's timecode. So if you wanted the time on the dispay to be 0 at 1 second ten frames in your comp you'd subract 1.4 seconds (at 25 fps) from <strong>time</strong> on the first line. Or if you wanted to start the count at 1 second 234ms you'd add 1.234 seconds. Or you could precomp it if that's too hard. Here's the code to copy 'n paste:</p>

<pre><code>offsettime=time //&lt;--subtract or add a time offset (in seconds) here

//a hacky way to zero pad the end of the ms field to
//three digits, but easier than doing it numerically:
ms=((offsettime % 1)+"000").substr(2,3);

//zero pad the seconds if they're less than 10. 
//"%" is the modulus operator, aka the remainder, so at 60s it rolls over:
s=Math.floor(offsettime % 60 );
ss=s&gt;9 ? s : "0"+s;

//and so on. Thank you ancient Mesopotamia for our weird time measurement system
m=Math.floor((offsettime / 60) % 60); 
mm=(m&gt;9) ? m : "0"+ m;
h=Math.floor( (offsettime / 3600) % 24);
hh=(h&gt;9) ? h  : "0"+ h;
//if whatever it is runs longer than 24hrs you're on your own

//now turn it all into a string:
hh + ":" + mm + ":" + ss + ":" + ms
</code></pre>

<p>note that the precision is limited by your comp's frame rate, so for 25fps the results will be just multiples of 40 ms. </p>

<p>Here it is applied (the red background is just the comp bg). Use normal text formatting to change the font etc (a monospaced one will work best).</p>

<p><img src="https://i.sstatic.net/YCVjf.png" alt="enter image description here"></p>

CC BY-SA 3.0
2014-10-18T14:28:28.173Z
2014-10-18T14:35:42.577Z
2014-10-18T14:35:42.577Z
stib
<p>I'm looking for a way to display a timer to measure things happening during the movie, a swimming event for example. </p>

<p>Can I add a timer that will start once the race is started and displaying in MM:SS:MS?</p>

<p>I have Adobe After Effects 2014 running on my Mac.</p>

CC BY-SA 4.0
2022-12-15T18:30:41.377Z
You can generate a WebP animation of a timer using my Javascript-based generator here: https://arpruss.github.io/webpanim/ . However, currently it'll only do MM:SS.X (one digit after the decimal point).
Alexander Pruss
<after-effects><timecode>
Adding a sport watch timer
Jens Jakobsen
# Adding a sport watch timer

(Asked by: username_0 on 2014-10-18)

I'm looking for a way to display a timer to measure things happening during the movie, a swimming event for example.

Can I add a timer that will start once the race is started and displaying in MM:SS:MS?

I have Adobe After Effects 2014 running on my Mac.

**Tags:** after-effects, timecode

> **Comments:**
> **username_1**: You can generate a WebP animation of a timer using my Javascript-based generator here: https://arpruss.github.io/webpanim/ . However, currently it'll only do MM:SS.X (one digit after the decimal point).  

---

## 1 answers

### Answer by username_2 on 2014-10-18. Score: 3

The Timecode effect (effects>text>timecode) will add a timecode, but it's measured in HH:MM:SS:FF rather than milliseconds. 
You could do it with an expression by adding a text layer, and applying an expression to the Source Text property. Below is an expression that returns what you want.
To apply it, alt-click on the stop watch for the text layers Source Text property and paste the expression in.

This expression includes an offset, because the time constant in AE starts at 0, no matter what your comp's timecode. So if you wanted the time on the dispay to be 0 at 1 second ten frames in your comp you'd subract 1.4 seconds (at 25 fps) from time on the first line. Or if you wanted to start the count at 1 second 234ms you'd add 1.234 seconds. Or you could precomp it if that's too hard. Here's the code to copy 'n paste:
offsettime=time //<--subtract or add a time offset (in seconds) here

//a hacky way to zero pad the end of the ms field to
//three digits, but easier than doing it numerically:
ms=((offsettime % 1)+"000").substr(2,3);

//zero pad the seconds if they're less than 10. 
//"%" is the modulus operator, aka the remainder, so at 60s it rolls over:
s=Math.floor(offsettime % 60 );
ss=s>9 ? s : "0"+s;

//and so on. Thank you ancient Mesopotamia for our weird time measurement system
m=Math.floor((offsettime / 60) % 60); 
mm=(m>9) ? m : "0"+ m;
h=Math.floor( (offsettime / 3600) % 24);
hh=(h>9) ? h  : "0"+ h;
//if whatever it is runs longer than 24hrs you're on your own

//now turn it all into a string:
hh + ":" + mm + ":" + ss + ":" + ms

note that the precision is limited by your comp's frame rate, so for 25fps the results will be just multiples of 40 ms. 
Here it is applied (the red background is just the comp bg). Use normal text formatting to change the font etc (a monospaced one will work best).


---

