# How to change a timer (the apperance and work in minutes and seconds)?

Hi, I have a project that requires a timer. I have manged to get a timer working, which counts up in seconds.
But how do I get the timer to work as a digital clock, so showing minutes and seconds (60 seconds = 1 minute).
Also is it possible to change the timer to not use a font, but instead use a sprite animation for the numbers (frame 1 = the number 1 on the timer, frame 2 = the number 2 on the timer…).
I have looked on the forums but couldn’t see any solution to this.
I hope someone can help.
Thank you.

`ToString(ceil(mod(TimerElapsedTime("Timer")/60,60))-1)+":"+ToString(ceil(mod(TimerElapsedTime("Timer"),60))-1)`

ceil at the beginning is changing any number into integer
Actually rounding it so if you have 1,0121558 it will display 2
If you have 0,0003 it will display 1
If you have 6,519551 it will display 7
That is why on end there is -1 so when integer would be 1 it will display 1
When it would be 2 it will display 2 and so go on

mod is looping number around that 60 on the end starting from 0
So it will go from 0 up to 59

First part have )/60,60))-1) and last have only ),60))-1)
Because in 1st we are dividing all seconds by 60
So when seconds reach 60 it will display 1 and +1 for each increment of 60
Meaning it will display minutes

Timer starts displaying 0:0
If you want it to show 00:00
Constantly

``````StrRepeat("0",(2 - StrLength(ToString(ceil(mod(TimerElapsedTime("Timer")/60,60))-1))))+ToString(ceil(mod(TimerElapsedTime("Timer")/60,60))-1)+":"+StrRepeat("0",(2 - StrLength(ToString(ceil(mod(TimerElapsedTime("Timer"),60))-1))))+ToString(ceil(mod(TimerElapsedTime("Timer"),60))-1)
``````

Where StrRepeat(“0”,(2 - StrLength
Means
Repeat 0 like shove it into that string
For 2 places of current string - length of whole string
So if timer have value of 0 so it is not started it will display 00 instead
I mean there is nothing to display so it will just shove in 2 ZERO digits there
When it should display 1 it will display 01
Because we ask it to repeat for 2 digits - length of output string
So if output string is 1 digit then it adds only ONE 0

As for changing it to sprite
You would need to split it into separate sprite for seconds and separate for minutes

Now
You would need to change current frame of seconds sprite to

``````ceil(mod(TimerElapsedTime("Timer"),60))-1```

While current frame of minutes sprite to

``````

ceil(mod(TimerElapsedTime(“Timer”)/60,60))-1

Zero’s expression makes sense to me and should work.

Note if you just want to display it as HH:MM:SS, there is an extension in the main extension this that will do this for you (“Time Formatter”).

Also, you should totally be able to set an animation to a timer, but keep in mind that the timer will count up infinitely, until you reset it.

If you have 20 frames of animation (keeping in mind that animation frames start at 0), you would just have an event that sets the animation of the object to floor(TimerElapsedTime(“YourTimerHere”")). You use Floor to round down, in order to ensure frame 0 gets shown until 1 second has passed.

Just make sure you reset the timer in a separate event once it is >= 19 seconds, so it doesn’t go to an invalid animation frame.

Thank you for your replies. They are very informative. I will attempt to put these comments into practice.