Highlighted

Timer Expression To Count Hours.

Community Beginner ,
Apr 30, 2020

Copy link to clipboard

Copied

Hello people! I would like help with an expression on a timer that counts hours. After a search I found this expression:

 

t = Math.floor (time);
minut = Math.floor (t / 60);
second = t% 60;
if (minut <10)
{
  if (second <10)
  {
   ['0' + minut + ':' + '0' + second];
  }
  else
  {
   ['0' + minut + ':' + second];
  }
}
else
{
  if (second <10)
  {
   [minut + ':' + '0' + second];
  }
  else
  {
   [minut + ':' + second];
  }
}

 

This expression works well, the only problem is that it does not count hours correctly. After 59:59 the timer goes to 60:00 and not 1:00:00. How could this expression be adjusted to work in a way that counts hours? If possible, show two expressions, one in the 1:00:00 format and the other in the 01:00:00 format.

 

Thanks in advance!

TOPICS
Expressions

Views

139

Likes

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

Timer Expression To Count Hours.

Community Beginner ,
Apr 30, 2020

Copy link to clipboard

Copied

Hello people! I would like help with an expression on a timer that counts hours. After a search I found this expression:

 

t = Math.floor (time);
minut = Math.floor (t / 60);
second = t% 60;
if (minut <10)
{
  if (second <10)
  {
   ['0' + minut + ':' + '0' + second];
  }
  else
  {
   ['0' + minut + ':' + second];
  }
}
else
{
  if (second <10)
  {
   [minut + ':' + '0' + second];
  }
  else
  {
   [minut + ':' + second];
  }
}

 

This expression works well, the only problem is that it does not count hours correctly. After 59:59 the timer goes to 60:00 and not 1:00:00. How could this expression be adjusted to work in a way that counts hours? If possible, show two expressions, one in the 1:00:00 format and the other in the 01:00:00 format.

 

Thanks in advance!

TOPICS
Expressions

Views

140

Likes

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
Apr 30, 2020 0
Adobe Community Professional ,
Apr 30, 2020

Copy link to clipboard

Copied

Your expression is only going to count minutes.

 

The best option is probably Dan Ebberts Up Down Counter

 

The article and the expression are pretty easy to understand.

Likes

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
Reply
Loading...
Apr 30, 2020 1
Community Beginner ,
Apr 30, 2020

Copy link to clipboard

Copied

Thank you! It helped a lot! Just one more doubt. Is it possible to make the text = outPoint time of the layer? Based on the expression I sent? For example: if the text layer is 03:30 in length, the text will be 03:30 and will remain in that number, without counting up or down, just remaining frozen in the time outPoint value of the layer, is it possible?

Likes

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
Reply
Loading...
Apr 30, 2020 0
Adobe Community Professional ,
Apr 30, 2020

Copy link to clipboard

Copied

If you use the Expression Language>Global Menu in the timeline you'll find the time to timecode operator. If you subtract the outPoint from the inPoint property you get the total time of the current layer.  "t" in the time to timecode operator is the time value. You can just do the calculation there. The result will be hours, minutes, seconds, and frames. By far the easiest way to eliminate hours or frames is to draw a mask on the text layer to hide those values. The duration option includes the last frame of the layer if set to true, but if it is set to false, the value reported does not include the time it would take to play the last frame.  Your expression would look like this:

timeToTimecode(t = outPoint - inPoint, timecodeBase = 30, isDuration = true)

If the comp's frame rate was 23.976 then you would set the timecodeBase to that value so the frame numbers would be accurate. That's all there is to it. 

Likes

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
Reply
Loading...
Apr 30, 2020 0