title: Formatting dates with moment JS to match
body: <p>I am using a third party API along with <a href="https://momentjs.com/" rel="nofollow noreferrer">Moment JS</a> for some date formatting in Javascript.  </p>
  
  <p>The third party API groups some data/results with an <code>epoch</code> date in milliseconds, such as:    </p>
  
  <pre><code>1559260800000
  </code></pre>
  
  <p><strong>This equates to</strong>:<br>
  GMT: Friday, 31 May 2019 00:00:00<br>
  Your time zone: Friday, 31 May 2019 01:00:00 GMT+01:00 DST<br>
  Relative: In 15 days  </p>
  
  <p>We are using a <a href="https://flatpickr.js.org/examples/" rel="nofollow noreferrer">Flatpickr</a> calendar for date selection. When a date is selected it returns the selected date in the local date format such as:  </p>
  
  <pre><code>Fri May 31 2019 00:00:00 GMT+0100 (British Summer Time)
  </code></pre>
  
  <p>If I use moment to convert that I get the following:  </p>
  
  <pre><code>var epoch = moment.utc(dayElem.dateObj).valueOf();
  </code></pre>
  
  <pre><code>1559257200000
  </code></pre>
  
  <p><strong>This equates to:</strong><br>
  GMT: Thursday, 30 May 2019 23:00:00<br>
  Your time zone: Friday, 31 May 2019 00:00:00 GMT+01:00 DST<br>
  Relative: In 15 days  </p>
  
  <p>I understand the issue relates to the local timezone and the first being GMT 00:00:00 and second being GMT 00:01:00 but I am unsure how to resolve it.  </p>
  
  <p>Furthermore, later dates in the year such as December when we are outside of BST the dates are GMT so I need this to work then too. </p>