• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Expression to create a static Timecode

Engaged ,
Nov 07, 2017 Nov 07, 2017

Copy link to clipboard

Copied

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)

TOPICS
Expressions

Views

2.5K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Nov 07, 2017 Nov 07, 2017

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

Votes

Translate

Translate
Community Expert ,
Nov 07, 2017 Nov 07, 2017

Copy link to clipboard

Copied

If you have iExpressions, you can use this one:

Counter Time Expression | mamoworld

counter_time_0.png

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

Javascript seconds to minutes and seconds - Stack Overflow

Mathias Möhl - Developer of tools like BeatEdit and Automation Blocks for Premiere Pro and After Effects

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Nov 07, 2017 Nov 07, 2017

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 07, 2017 Nov 07, 2017

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Nov 07, 2017 Nov 07, 2017

Copy link to clipboard

Copied

Amazing!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Nov 07, 2017 Nov 07, 2017

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 07, 2017 Nov 07, 2017

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Nov 07, 2017 Nov 07, 2017

Copy link to clipboard

Copied

Thank you a lot!!!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 16, 2022 Feb 16, 2022

Copy link to clipboard

Copied

LATEST

Here is a super simple expression that will do this.

countTime = timeToCurrentFormat(time);
countTime.substr(3, 5);

 You can also just add how many frames you want to the (time) with something like (time+30) to start at 1 second if you're frames per second is 30. The .substr just trims the string generated by the timeToCurrentFormat so right now it is trimming from the 3rd character to the 5th. If you shift those numbers to something like (6,7) you can show seconds/frames  or (0, 5) for hours minutes or whatever you want.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines