title: Determine if local datetime is within a datetime window
body: <p>I'm working on code to determine if the current local datetime falls within a datetime range, a start and end datetime.</p>
  <p>I start by getting the start and end datetime values as a serialized GMT string (this is what the source system is returning to me):</p>
  <pre><code>let myStartDate = &quot;2020-09-11T14:15:13.000Z&quot;;
  let myEndDate = &quot;2020-09-15T01:09:34.000Z&quot;;
  </code></pre>
  <p>I then convert the datetime to UTC format:</p>
  <pre><code>let startDate = new Date(myStartDate).toUTCString();
  let endDate = new Date(myEndDate).toUTCString();
  let now = new Date().toUTCString();
  </code></pre>
  <p>Then I check to see if <code>now</code> is between the <code>startDate</code> and <code>endDate</code>:</p>
  <pre><code>if (now &gt; startDate &amp;&amp; now &lt; endDate) {
    console.log(&quot;You're INSIDE the datetime window!&quot;);
  } else {
    console.log(&quot;You're OUTSIDE the datetime window!&quot;);
  }
  
  console.log(&quot;Now:   &quot; + new Date(now));
  console.log(&quot;Start: &quot; + new Date(startDate));
  console.log(&quot;End:   &quot; + new Date(endDate));
  </code></pre>
  <p>When I run this, my code is telling me I'm outside the datetime window, even though the start and datetime values are a couple days before and after my current datetime.</p>
  <p>An alternative I see is using <code>getTime()</code>, which converts the datetime to a UTC milliseconds number.</p>
  <pre><code>let startDate = new Date(myStartDate).getTime();
  let endDate = new Date(myEndDate).getTime();
  let now = new Date().getTime();
  </code></pre>
  <p>This seems to work, but I'm confused why <code>toUTCString()</code> can't be evaluated the same way.</p>