title: Converting an <audio> tags track time into Mins:Secs
body: <p>I created a frankensteined audio player, and need a little help with the track timing. I have it now so it counts from 0 -> whatever the track time is, in seconds. I can't seem to figure out how to convert those seconds into mins:secs.</p>
  
  <p>I'm new to timing/converting with JS, so any help is appreciated!</p>
  
  <p>HTML</p>
  
  <pre><code>    &lt;audio src="" id="player" 
          ontimeupdate="document.getElementById('tracktime').innerHTML = Math.floor(this.currentTime) + ' ' + Math.floor(this.duration);"&gt;\
  &lt;/audio&gt; 
  
      &lt;span id="tracktime"&gt;0  0:00&lt;/span&gt;
  </code></pre>
  
  <p><strong>CODE UPDATE</strong></p>
  
  <p>Alright, so I now have it so it just shows minutes as a single digit (ie: 1:00 = 1, 2:00 = 2, 3:00=3, etc)</p>
  
  <p>I need it to show it as 3 digits, ie: 1:00 = 1:00, 2:00 = 2:00, etc.</p>
  
  <p><strong>Here is my current audio tag:</strong></p>
  
  <pre><code>&lt;audio src="http://dosh.dk/bb/track.mp3" id="player" ontimeupdate="document.getElementById('tracktime').innerHTML = Math.floor(this.currentTime / 60) + ' ' + Math.floor(this.duration / 60);"&gt;
      &lt;script&gt;
        var minutes = Math.floor(time / 60);
  
        var seconds = time - minutes * 60;
  
        var hours = Math.floor(time / 3600);
  time = time - hours * 3600;
  
        function str_pad_left(string,pad,length) {
      return (new Array(length+1).join(pad)+string).slice(-length);
  }
        &lt;/script&gt;
  
      &lt;/audio&gt; 
  </code></pre>
  
  <p>I just can't seem to concatenate the seconds onto the minutes.</p>