title: Correct way to use moment.js to convert a series of non-UTC timestamps that cross the Fall DST boundary to UTC timestamps?
body: <p><strong>Background</strong></p>
  
  <p>I am investigating different use cases of moment.js for a project but am stumped on the issue of daylight savings ending in the fall. Before asking my question, since I want to be clear and provide background for others who have similar questions, let me explain what I am doing and what found with spring daylight savings.</p>
  
  <p>First, I am working with UTC timestamps and America/New_York timestamps. In the US, daylight savings in 2017 begins on March 12 at 2AM (skipping from  2:00:00AM to 3:00:00AM) and ends on November 5 at 2AM (reverting from 2:00:00AM to 1:00:00AM). Since I also always know the target time zone (America/New_York) that I need to convert to, I will not rely upon moment.js to detect my local time zone and instead explicitly specify the time zone I want.</p>
  
  <p>During the spring when daylight savings goes into effect, the time zones that observe daylight savings, like America/New_York, jump forward an hour. moment.js handles this just fine. </p>
  
  <p>For example, if I pass moment.js a UTC timestamp for the time one second before daylight savings goes into effect for America/New_York, it looks like this:</p>
  
  <pre><code>moment('2017-03-12T06:59:59Z').tz('America/New_York').format('YYYY/MM/DD hh:mm:ss a z')
  </code></pre>
  
  <p>The input above is taken as UTC because of the <code>Z</code> on my timestamp and I am explicitly setting the target timezone with <code>.tz('America/New_York')</code> so that it doesn't use local system time.</p>
  
  <p>Alternatively using moment-timezone I can explicitly set the input time zone as UTC and set the output as America/New_York.</p>
  
  <pre><code>moment.tz('2017-03-12T06:59:59', 'UTC').tz('America/New_York').format('YYYY/MM/DD hh:mm:ss a z')
  </code></pre>
  
  <p>Either way, the result is <code>2017/03/12 01:59:59 am EST</code>.</p>
  
  <p>Then, I run the same commands for a moment just one second later. I will just use the format given in the first example above where I specify the time as UTC and then convert it to America/New_York time:</p>
  
  <pre><code>moment('2017-03-12T07:00:00Z').tz('America/New_York').format('YYYY/MM/DD hh:mm:ss a z')
  </code></pre>
  
  <p>And my result is correct as expected: <code>2017/03/12 03:00:00 am EDT</code> - due to daylight savings the time skipped ahead by one hour.</p>
  
  <p>I can then use moment-timezone to go back the other way by passing in an America/New_York timestamp and converting it to UTC.</p>
  
  <pre><code>moment.tz('2017-03-12T01:59:59', 'America/New_York').utc().format('YYYY/MM/DD hh:mm:ss a z')
  </code></pre>
  
  <p>This gives me <code>2017/03/12 06:59:59 am UTC</code></p>
  
  <p>And the next moment in the America/New_York time zone, because of daylight savings coming into play, is 03:00:00 so I convert that to UTC...</p>
  
  <pre><code>    moment.tz('2017-03-12T03:00:00', 'America/New_York').utc().format('YYYY/MM/DD hh:mm:ss a z')
  </code></pre>
  
  <p>... and get <code>2017/03/12 07:00:00 am UTC</code> which looks correct.
  An hour was skipped ("lost") in America/New_York time, but moment can detect that and convert it to UTC.</p>
  
  <p>In Summary, for the spring daylight savings change in the US, I can pass a UTC timestamp into either moment.js or moment-timezone and get back a timestamp in another time zone with the correct daylight savings offset also applied. I can also then pass an America/New_York timestamp into moment and get back a correctly converted UTC timestamp.</p>
  
  <p><strong>My Question</strong></p>
  
  <p>Great, so I want to do the same thing when daylight savings ends in the fall and of course it isn't that simple. My hypothesis is that due to daylight savings effectively causing an hour to "repeat", there is no way for moment to know the correct time UTC. In other words, where there was a gap of one hour when daylight savings started, now we have overlap of one hour.</p>
  
  <p>Question (part 1): Is there a way to pass a relative timestamp and time zone into moment and get back the correct UTC time? When I tried this in the examples below, moment skips an hour on the UTC side.</p>
  
  <pre><code>moment.tz('2017-11-05T01:00:00', 'America/Denver').tz('UTC').format('YYYY/MM/DD hh:mm:ss a z') =&gt; "2017/11/05 07:00:00 am UTC"
  moment.tz('2017-11-05T01:59:59', 'America/Denver').tz('UTC').format('YYYY/MM/DD hh:mm:ss a z') =&gt; "2017/11/05 07:59:59 am UTC"
  moment.tz('2017-11-05T02:00:00', 'America/Denver').tz('UTC').format('YYYY/MM/DD hh:mm:ss a z') =&gt; "2017/11/05 09:00:00 am UTC"
  moment.tz('2017-11-05T02:59:59', 'America/Denver').tz('UTC').format('YYYY/MM/DD hh:mm:ss a z') =&gt; "2017/11/05 09:59:59 am UTC"
  </code></pre>
  
  <p>I assume its because time is happening chronologically like in the example below. UTC offset context is not given therefore I assume that moment cant distinguish between the America/New_York timestamps preceded by asterisks:</p>
  
  <pre><code>*2017/11/05 01:00:00 am America/New_York =&gt; 2017/11/05 07:00:00 am UTC
  *2017/11/05 01:59:59 am America/New_York =&gt; 2017/11/05 07:59:59 am UTC
  *2017/11/05 01:00:00 am America/New_York =&gt; ???
  *2017/11/05 01:59:59 am America/New_York =&gt; ???
  2017/11/05 02:00:00 am America/New_York =&gt; 2017/11/05 09:00:00 am UTC
  2017/11/05 02:59:59 am America/New_York =&gt; 2017/11/05 09:59:59 am UTC
  </code></pre>
  
  <p>Again, what I want to know is if there is a way around this? Currently the timestamps in the data that I have does not contain UTC offsets.</p>
  
  <p>Question (part 2): If I am presenting data in the America/New_York time zone then is it correct to think that I will essentially have two hours of data points all stuffed into a (seemingly) single one hour period from 01:00:00 to 01:59:59 on November 5, 2017?</p>
  
  <p><strong>Related Topics</strong></p>
  
  <p>There are a few other topics on SO that are related to this but none that I have found pose or answer this same question. I will link a few here for reference:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/29114824/moment-js-convert-local-time-to-utc-time-does-work">Moment.js Convert Local time to UTC time does work</a></li>
  <li><a href="https://stackoverflow.com/questions/34281933/initialize-a-moment-with-the-timezone-offset-that-i-created-it-with">Initialize a Moment with the timezone offset that I created it with</a></li>
  </ul>