title: Invalid Time Value in Javascript
body: <p>I have got a div that is populated using javascript. Once this is loaded I run another javascript code to get the date from the date e.g saturday. The issue i believe seems with the incorrect selector that displays the date.</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>$(document).ready(function() {
    var i = setInterval(function() {
      if ($('#am-events-booking').text().length) {
        clearInterval(i);
        console.log('Text detected!');
  
  
        var day = new Intl.DateTimeFormat('en-US', {
          weekday: 'long'
        }).format(
          new Date(
            document.querySelector('.am-event-sub-info &gt; div')
            .innerHTML
            .split(' - ')[0] // only interested in the "February 27, 2021 11:30 am" part
          )
        );
  
        document.querySelector('.am-event-sub-info').innerHTML += '&lt;div class="day"&gt;' + day + '&lt;/div&gt;';
  
  
        console.log(
          new Intl.DateTimeFormat('en-US', {
            weekday: 'long'
          }).format(
            new Date(
              document.querySelector('.am-event-sub-info &gt; div')
              .innerHTML
              .split(' - ')[0] // only interested in the "February 27, 2021 11:30 am" part
            )
          )
        );
  
  
  
  
      } else {
        console.log('Waiting...');
      }
    }, 5000);
    console.log('Page is loaded');
  });</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;div id="am-events-booking"&gt;
  
  
    &lt;div id="am-event-22" class="am-event" style="pointer-events: all;"&gt;
      &lt;div class="am-event-data"&gt;
  
        &lt;div class="am-event-info"&gt;
          &lt;div class="am-event-sub-info"&gt;
            &lt;div class="am-event-sub-info-capacity"&gt;&lt;img src=""&gt; Capacity: 0 / 100&lt;/div&gt;
            &lt;!----&gt;
          &lt;/div&gt;
          &lt;div class="am-event-sub-info"&gt;
            &lt;div&gt;&lt;img src=""&gt; Saturday, February 27th, 2021 11:30 am - 1:00 pm&lt;/div&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  <p>I get invalid time value</p>