How can i show my timer in mm:ss format?

Hello :smiley: ,

I have created a Timer script but not able to figure out how can i show it in mm:ss format. Right now it shows only single number when it goes less than 10. Right now it shows like this (1 minutes 5 seconds)
I want to achieve(01 minutes 05 seconds). any idea how can i achieve this?
Sharing my code below. Thanks in Advance :smiley:

var Timer = pc.createScript('timer');

Timer.attributes.add('textElement', {type: 'entity'});
Timer.attributes.add('timeout', {type: 'entity'});
Timer.attributes.add('mcq', {type: 'entity'});
Timer.attributes.add('timeTaken', {type: 'entity'});



var currQue;

//correct one
// initialize code called once per entity
Timer.prototype.initialize = function() {

     
    this.timeout.enabled = false;
    this.mcq.enabled = true;


    this.timer = 1200;
    this.updateText();
    this.updateTimeTaken();
};

// update code called every frame
Timer.prototype.update = function(dt) {

    if(this.timerActive)
    {
        this.timer -= dt;
    }

    this.timeTakenNo = 1200 - this.timer;
    this.updateText();
    this.updateTimeTaken();

    
    if(this.timer <= 0) {
        this.timerActive = false;
        this.timer += 1200;
        this.timeout.enabled = true;
        this.mcq.enabled = false;
        }
};

Timer.prototype.updateText = function() {
    var roundedTimer = Math.floor(this.timer);
    var minutes = Math.floor(roundedTimer / 60);
    var seconds = Math.floor(roundedTimer % 60);

    this.textElement.element.text = minutes + ":" + seconds;

};

Timer.prototype.updateTimeTaken = function() {
    var roundedTimer = Math.floor(this.timeTakenNo);
    var minutes = Math.floor(roundedTimer / 60);
    var seconds = Math.floor(roundedTimer % 60);


    this.timeTaken.element.text = minutes + " mins " + seconds + " secs";
};

Hi @Vivek_Chaini!

You can check my timer project if you want.

https://playcanvas.com/project/950552/overview/timer