I'm trying to create an expression that changes source text from minutes to hours.

Here is an example of the graphic I'm animating:

animation snippet

As you can see the 3 hours counter is on hold, I want that to start from 0 minutes and increase till 60 to then swap to hours and gradually reach 3.

I will apply that too on the blue bar which currently displays '60 min' instead of '1 hour'. Of course, I can work around it but I'd love to know a working expression.


1 Answer 1


Make three text layers with a slider on each. Call the layers value 1, value 2, and value 3.

In the source text of each of the text layers put this expression, to display the slider value and round it to the nearest minute:

slider = (effect("Slider Control")("Slider").value);
rounding = (Math.round(slider));
SourceText = rounding + " minutes"

Make a text layer called total.

Put the following in its source text as an expression

totalmins = thisComp.layer("value 1").effect("Slider Control")("Slider") + thisComp.layer("value 2").effect("Slider Control")("Slider") + thisComp.layer("value 3").effect("Slider Control")("Slider")

if (totalmins <60) {
    SourceText = totalmins + " minutes" } else
        if (totalmins > 61) {
        SourceText = Math.round((totalmins/60)*10)/10 + " hours" } 
        "1 hour"

totalmins is a variable which adds up the total minutes from the sliders in the other layers.

If the total is under 60 minutes, it displays the total in minutes with the text " minutes" appended to it.

If the total is over 61 minutes, it displays the total time in hours, to one decimal place (the Math.round function normally rounds to the nearest whole number, so confusingly we have to multiply it by 10, then divide by 10 outside it to get one decimal place). Watch out for the capital letter on "Math".

Otherwise, display "1 hour".


  • Wow, this is great! Thank you so much! I just had an issue, the total wasn't rounding up from 0 to 60m but only after, so I added math.round after totalmins. Commented Nov 16, 2021 at 14:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.