title: Formatting Date and Time With ECMAScript Internationalization API
body: <p>I need to have a javascript date/time formatted like: </p>
  
  <p><strong>February 16, 2015 06:31:00 AM</strong></p>
  
  <p>I was going to use <code>toLocaleTimeString</code> with some options, but the code I tried below doesn't seem to work in Chrome.</p>
  
  <pre><code>function getFormattedDateTime(dateTimeToFormat) {
  dateTimeToFormat = new Date(dateTimeToFormat);
  var monthOptions = {
      month: 'long', year: 'numeric', day: 'numeric',
      hour: '2-digit', minute: '2-digit', second: '2-digit'
  };
  
  return dateTimeToFormat.toLocaleTimeString('en-us', monthOptions);
  }
  </code></pre>
  
  <p>The output from the above code is <em>February 16, 2015, 6:31 AM</em></p>
  
  <p>It's close, but no cigar.
  jQuery is an option as well if it has any better date formatting utilities. jQuery only though, no plugins, please.</p>
  
  <p>Here is a JSFiddle to save some time: <a href="https://jsfiddle.net/gxze230b/" rel="nofollow noreferrer">https://jsfiddle.net/gxze230b/</a></p>
  
  <p>After a typo correction, the output string is now: <strong>February 16, 2015, 6:31:00 AM</strong></p>