title: How to make sure parseInt() function does not return unexpected results
body: <p>The following is a method that converts millisecond to human-readable time. However I got a comment about it that says it might return unexpected result for some radix.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function msToTime(duration, sign) {
    var milliseconds = parseInt((duration % 1000) / 100),
      seconds = parseInt((duration / 1000) % 60),
      minutes = parseInt((duration / (1000 * 60)) % 60),
      hours = parseInt((duration / (1000 * 60 * 60)) % 24);
  
    hours = (hours &lt; 10) ? "0" + hours : hours;
    minutes = (minutes &lt; 10) ? " " + minutes : minutes;
    seconds = (seconds &lt; 10) ? "0" + seconds : seconds;
  
    return minutes + sign + seconds;
  }
  
  $("div").text(msToTime(1203400, ":"));</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt;
  
  
  &lt;div&gt;&lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>This is the comment I have received: <em>"The <code>parseInt()</code> function can return undesired and/or unexpected results if the radix is not supplied.Please make sure a radix is used on all <code>parseInt()</code> instances."</em></p>
  
  <p>I tried to add day, week, month, year and so on, but I am not sure if that's the right way. Also it is for a duration of music. So there won't be any case for longer than hours I think.</p>
  
  <p>Any idea to make sure the result of the method is always correct?</p>