Javascript Number toTime()

Description

Javascript Number toTime()

Number.prototype.toTime = function() {
  if (this < 10) {
    return '0' + this;
  } else {//  w w w.j a  va2 s  .c  o m
    return this + '';
  }
}

Javascript Number toTime()

Number.prototype.toTime = function () {
  var mins = Math.floor(this / 60);
  var secs = (this % 60).toFixed();
  return (mins < 10 ? "0" : "" ) + mins + ":" + (secs < 10 ? "0" : "" ) + secs;
};



PreviousNext

Related