Skip to main content
fcvideo
Inspiring
May 4, 2015
Answered

Football Clock

  • May 4, 2015
  • 2 replies
  • 1927 views

Hi (again) - After Effects CS6

I need to create a clock in After Effects that runs the whole length of a football match (45 mins each half).

Looking at code in a template I brought - I have this expression:

countspeed = 1;

clockStart = 0;

function times(n){

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

}

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

if (clockTime < 0){

  minus = "-";

  clockTime = -clockTime;

}else{

  minus = "";

}

t = Math.floor(clockTime);

h = Math.floor(t/3600);

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

sec = Math.floor(t%60);

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

times(min) + ":" + times(sec) + ""

Now I worked out that by changing the 'clockStart = 0;' to = 2700, I have a 2nd half which starts at 45 mins, which is what I want.

But is there a way to show that when a match gets to 45 mins (or 90 mins in 2nd half) that instead of it going to 45.01.... it shows 45.00 +0.01, 45.00 +0.02 (as technically 46.00 is in the 2nd half)

Thanks for looking and any potential help you can provide

Lee

This topic has been closed for replies.
Correct answer thomase11803634

Hi fcvideo,

you need to understand to code you type in, check this

Lesson06 – Counter and Text Formatting | AExpr Breakdown

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

this part resets the minute counter every 60 minutes

modulo is like a loop maker, every 3600 seconds, it resets the value to 0, this should do the trick:

min = Math.floor(t/60);

2 replies

Mathias Moehl
Community Expert
Community Expert
May 8, 2015

If you don't like to write or modify expressions code, you can also easily generate counters with Source Text Bundle of iExpressions.

iExpressions supports counters for Time, Dates and simple Numbers and is both simple and flexible in formatting those.

If you want 65 minutes to be shown as 65 minutes instead of 1 hour and 5 minutes, simply use the Counter Numbers instead of the Counter Time expression.

See this tutorial for an overview of creating counters with iExpressions.

Mathias Möhl - Developer of tools like BeatEdit and Automation Blocks for Premiere Pro and After Effects
Mylenium
Legend
May 4, 2015

Simply use a second layer and some manually typed text. I honestly don't get why people always want to do such a simple thing the hard way with expressions when they don't understand them.

Mylenium

fcvideo
fcvideoAuthor
Inspiring
May 4, 2015

That's actually a good call - didn't even consider that.

Just 1 last question then - is there a way to keep the minutes from converting to hours - ie 65 mins = 65 not 1 hour 5 mins

thomase11803634Correct answer
Inspiring
May 5, 2015

Hi fcvideo,

you need to understand to code you type in, check this

Lesson06 – Counter and Text Formatting | AExpr Breakdown

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

this part resets the minute counter every 60 minutes

modulo is like a loop maker, every 3600 seconds, it resets the value to 0, this should do the trick:

min = Math.floor(t/60);