jquery-runner icon indicating copy to clipboard operation
jquery-runner copied to clipboard

How to Format?

Open brucfo opened this issue 10 years ago • 1 comments

Hi,

I'm with problem, when I have the time 01:00.00 or 01:00 the time when start show 59 or 59.xx (milliseconds) how to format to 00:59.xx and 00:59 How can I format this way?

brucfo avatar Apr 26 '14 04:04 brucfo

To display 02:10:08 instead 2:10:8 you can use this code:

format: function(m, s){
  var sec = Math.floor((m / 1000) % 60);
  var min = Math.floor((m / 60000) % 60);
  var hor = Math.floor((m / 3600000) % 24);

  sec = sec < 10 ? '0' + sec : sec;
  min = min < 10 ? '0' + min : min;
  hor = hor < 10 ? '0' + hor : hor;
  return hor + ':' + min + ':' + sec;
}

glaucocustodio avatar Oct 24 '14 16:10 glaucocustodio