title: Add "am" or "pm" to Specific Time Format Dependent on Time of Day - Javascript
body: <p>I have the following javaScript which is showing the time in hours and minutes.</p>
  
  <p>Is there a way of having an "am" or "pm" next to the time, dependent on whether it's before or after midday?</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 t = new Date();
  var time = document.getElementById("time");
  
  time.textContent = t.getHours() + ":" + t.getMinutes();</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;h3 class="time-holder"&gt;Current UK time: &lt;span id="time"&gt;12:00&lt;/span&gt;&lt;/h3&gt;</code></pre>
  </div>
  </div>
  </p>