Hi I downloaded this very elegant javascript for a countdown timer which reverts back to menu page when it reaches zero but I can’t figure out how to change the countdown from seconds to minutes and seconds i.e. 2 minutes needs to be displayed as 2:00 and not 120. Been looking for ages for an answer so any help would be much appreciated.

```
var timerText : GUIText;
var roundTime = 60.0;
var thisSecond;
var lastSecond = 0;
function Update () {
thisSecond = Mathf.FloorToInt(Time.time);
if(thisSecond > lastSecond)
{
roundTime -= 1;
timerText.text = roundTime.ToString();
}
if(roundTime < 1)
{
Application.LoadLevel(0);
}
lastSecond = thisSecond;
}
```

to turn seconds into minutes you do 2 operations. First is for the number of minutes, the second is for the remaining seconds.

To get the minutes first divide your total seconds by 60 then do Mathf.Floor on it’s result. i.e.

var minutes = Mathf.Floor(totalSeconds / 60);

To get the remaining seconds you do a special type of division that returns the remainder. Instead of doing a division (e.g. 120 / 60) use the percentage symbol (i.e. 120 % 60). i.e.

var remainingSeconds = totalSeconds % 60;

hope this helps

Actually sorted it myself (or to be correct my son did). If from line 15 the first “if” statement you add the following it works perfectly.

```
if(thisSecond > lastSecond)
{
roundTime -= 1;
minutes = Mathf.FloorToInt(roundTime/60);
seconds = roundTime % 60;
timerText.text = minutes + ":" + seconds;
}
```