7 Replies Latest reply on Nov 7, 2017 10:42 AM by ti.s.cavalcanti

# Expression to create a static Timecode

I need to create a "Timecode" so: 00:00, and this will show the value of a propertie, example: when the value 145 (corresponds to me like 145 seconds). So the Timecode get 2:24

Basically I want to convert a value (which I have as seconds) to minutes and seconds (00:00)

• ###### 1. Re: Expression to create a static Timecode

If you have iExpressions, you can use this one:

if you want to write your own expression, you need to convert the time to minutes and seconds as described here

• ###### 2. Re: Expression to create a static Timecode

How to aply this function in my expression?:

```function fancyTimeFormat(time)
{
// Hours, minutes and seconds
var hrs = ~~(time / 3600);
var mins = ~~((time % 3600) / 60);
var secs = time % 60;

// Output like "1:01" or "4:03:59" or "123:03:59"
var ret = "";

if (hrs > 0) {
ret += "" + hrs + ":" + (mins < 10 ? "0" : "");
}

ret += "" + mins + ":" + (secs < 10 ? "0" : "");
ret += "" + secs;
return ret;
}```

I need the value of the property, or in this case, the effect value:

comp ("Comp 1"). layer ("Null 1"). effect ("Slider Control")

To be used as the base of seconds, and then get the result in minutes and seconds.

• ###### 3. Re: Expression to create a static Timecode

Something like this maybe:

t = parseInt(comp("Comp 1").layer("Null 1").effect("Slider Control")("Slider"),10);

mm = Math.floor(t/60).toString();

if (mm.length < 2) mm = "0" + mm;

ss = (t%60).toString();

if (ss.length < 2) ss = "0" + ss;

mm + ":" + ss

Dan

• ###### 4. Re: Expression to create a static Timecode

Amazing!

• ###### 5. Re: Expression to create a static Timecode

Do you can add the frames too in this expression for me, please?

Beyond minutes and secs...

I try this, is right?:

t = parseInt(comp("Comp 1").layer("Null 1").effect("Slider Control")("Slider"),10);

mm = Math.floor(t/60).toString();

if (mm.length < 2) mm = "0" + mm;

ss = (t%60).toString();

if (ss.length < 2) ss = "0" + ss;

ff = Math.floor(t/29.97).toString();

if (ff.length < 2) ff = "0" + ff;

mm + ":" + ss + ":" + ff

• ###### 6. Re: Expression to create a static Timecode

I guess I'd do it like this:

slider = comp("Comp 1").layer("Null 1").effect("Slider Control")("Slider");

t = parseInt(slider,10);

ff = timeToFrames(slider%1).toString();

if (ff.length < 2) ff = "0" + ff;

mm = Math.floor(t/60).toString();

if (mm.length < 2) mm = "0" + mm;

ss = (t%60).toString();

if (ss.length < 2) ss = "0" + ss;

mm + ":" + ss + ":" + ff

Dan