title: Moment js Date values comparison across time-zones
body: <p>I am getting 4 dates as inputs mentioned below from an external source.</p>
  
  <p><strong>Dates with time element:</strong></p>
  
  <pre><code>"InitialDate": "2019-02-19T12:03:22.129Z",
  "updateDate": "2019-02-28T05:26:57.115Z",
  </code></pre>
  
  <p><strong>Dates without time element:</strong></p>
  
  <pre><code>"startDate": "2019-02-18",
  "endDate": "2020-02-16",
  </code></pre>
  
  <p>I am coverting <strong>InitialDate</strong> and <strong>updateDate</strong> and creating <strong>actualInitDatE</strong> out of them using a moment format as below, as they are getting time element also in it.</p>
  
  <p>I don't want time element and i only want date elements of all the 4 dates.</p>
  
  <pre><code>   const actualInitDatE = moment(InitialDate).format('MM-DD-YYYY') || 
    moment(updateDate).format('MM-DD-YYYY');
  </code></pre>
  
  <p>Now, I am converting the <strong>startDate</strong> and <strong>endDate</strong> which are having only date element in it (and no time element) and finally creating <strong>actualStartDate</strong> and <strong>actualEndDateW</strong> variables,</p>
  
  <pre><code>const actualStartDateW = moment(startDate).format('MM-DD-YYYY');
  const actualEndDateW = moment(endDate).format('MM-DD-YYYY');
  </code></pre>
  
  <p>Now I am comparing them with the below logic and is working fine in IST,    </p>
  
  <pre><code>if (actualInitDatE &gt;= actualStartDateW &amp;&amp; actualInitDatE &lt;= actualEndDateW) {
            console.log('Compared and True');
  }
  </code></pre>
  
  <p>My Doubt is will this work correctly in UTC and other time zones as well? I am doubtful because some of the dates have time elements and some of them have only the date elements.</p>
  
  <p>I have gone through this and implemented the approach. Is this approach is correct or do we need to use any offset?</p>
  
  <p><strong><a href="https://stackoverflow.com/questions/29174810/javascript-date-timezone-issue">javascript Date timezone issue</a></strong></p>
  
  <p>Can someone help me in this regard and let me know if this code works across timeZones?</p>