title: Can not get proper time format using javascript/jquery
body: <p>I need one help .I need to get proper time interval format using Javascript/Jquery.</p>
  
  <p><strong>JS :</strong></p>
  
  <pre><code>document.getElementById('btn').onclick=function(){
      var num=6;
      var sTime=9;
      var duration=1;
      var arr = [],
      endTime,
      startTime = sTime;
      for (var i = 0; i &lt; num; i++) {
      endTime = startTime + duration;
      var inp = document.createElement("input");
      inp.type = "text";
      var ampm = startTime &lt;= 12 &amp;&amp; endTime &lt;= 12 ? " AM " : " PM "
      inp.setAttribute("placeholder", startTime + ampm + endTime + ampm);
      document.body.appendChild(inp);
      startTime = endTime;
    }
  }
  </code></pre>
  
  <p>Here i need after 12 o clock it should be 1,2...AM/PM .In my case its coming 13 after 12PM.Here is the <a href="http://plnkr.co/edit/lshvVmqwFH70n7KIbM8x?p=preview" rel="nofollow">Plunkr link</a> to check.Please help me.</p>