title: How do I format a number with a leading zero?
body: <p>My time is updating in realtime with the following function:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>    var nIntervId;
  
      function updateTime() {
          nIntervId = setInterval(flashTime, 1000*2);
      }
  
      function flashTime() {
          var now = new Date();
          var h = now.getHours();
          var m = now.getMinutes();
          var s = now.getSeconds();
          var time = h + ':' + m;
          $('.time').html(time);
      }
  
      $(function() {
          updateTime();
      });</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;span class="time" style="margin-left:20px"&gt;&lt;/span&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>Problem ist, that it is displaying <code>11:9</code>  instead if <code>11:09</code></p>