title: Momentjs countdown - Duration is showing negative numbers
body: <p>I am tring to create a countdown with MomentJS (<code>2.22.2</code>) and Rxjs (<code>6.2.2</code>) <code>interval</code>. But when I reach some points in time my countdown goes crazy and outputs negative numbers, where it should have, for example, substracted a day and started at 23 hours. </p>
  
  <p>Any help on how I should fix this?</p>
  
  <hr>
  
  <p><strong>Example</strong></p>
  
  <p>local time: <code>2018-09-05T18:49</code></p>
  
  <p>End time: <code>2018-11-03T18:00</code></p>
  
  <p>this results in:</p>
  
  <p><a href="https://i.stack.imgur.com/6Ey9u.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6Ey9u.png" alt="Negative countdown"></a></p>
  
  <hr>
  
  <p><strong>My code</strong></p>
  
  <p>'<code>this.days</code>', '<code>this.hours</code>', '<code>this.minutes</code>' &amp; '<code>this.seconds</code>' are local variables that hold a string representation of the resulting time (string format, because I want to show leading zero's)</p>
  
  <pre><code>interval(1000).subscribe(() =&gt; {
        const now = moment();
        let timeLeft = this.endDate.diff(now, 'milliseconds', true);
        let endDate = moment(this.endDate); // Use 'moment' to make a new copy
  
        // Days
        const days = Math.floor(moment.duration(timeLeft).asDays());
        console.warn(moment.duration(timeLeft).asDays());
        this.days = Countdown.addLeadingZeros(days.toString(), 3);
  
        endDate = endDate.subtract(days, 'days');
        timeLeft = endDate.diff(now, 'milliseconds', true);
  
        // Hours
        const hours = Math.floor(moment.duration(timeLeft).asHours());
        console.warn(Math.round(moment.duration(timeLeft).asHours()));
        this.hours = Countdown.addLeadingZeros(hours.toString(), 2);
  
        endDate = endDate.subtract(hours, 'hours');
        timeLeft = endDate.diff(now, 'milliseconds', true);
  
        // Minutes
        const minutes = Math.floor(moment.duration(timeLeft).asMinutes());
        this.minutes = Countdown.addLeadingZeros(minutes.toString(), 2);
  
        endDate = endDate.subtract(minutes, 'minutes');
        timeLeft = endDate.diff(now, 'milliseconds', true);
  
        // Seconds
        const seconds = Math.floor(moment.duration(timeLeft).asSeconds());
        this.seconds = Countdown.addLeadingZeros(seconds.toString(), 2);
  });
  </code></pre>
  
  <hr>
  
  <p>Does anyone see what I am doing wrong here or how I could improve this code?</p>