 <p>see this <a href="http://jsfiddle.net/naeemshaikh27/bvz0opy9/2/" rel="nofollow">Fiddle</a> </p> <p>you just need to set hours to midnight 12. You can do it like this <code>d.setHours(0,0,0,0);</code></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>var today = true; var d = new Date(), till = new Date(), t, h, m; d.setHours(0, 0, 0, 0); if (today) { till.setDate(d.getDate() + 1); till.setHours(0, 0, 0, 0); while (d &lt;= till) { h = d.getHours(); m = d.getMinutes(); t = h % 12; t = t == 0 ? 12 : t; $('#time').append('&lt;li&gt;' + (t &lt; 10 ? '0' : '') + t + ':' + (m &lt; 10 ? '0' : '') + m + ' ' + (h &lt; 12 || h == 24 ? 'AM' : 'PM') + '&lt;/li&gt;'); d.setMinutes(m + 15); } } else { // print full list of time }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"&gt;&lt;/script&gt; &lt;div id="time"&gt;&lt;/div&gt;</code></pre> </div> </div> </p>