title: Calculate the difference between two dates in javascript using react
body: <p>I'm trying to get the difference between two date in react whith two datepicker and two timepicker ( a react component ). The date is for a booking and I want to get the duration by substract the "end date" with "start date", but when I subtract two date whith more than 24 hours I have a -152 or a value that not corresponding to the real duration.</p>
  
  <p>The code</p>
  
  <pre><code>periodReserve = (e, idPark, title ) =&gt; {
  let Start_Day = this.state.startDate &amp;&amp; this.state.startDate.format(Formatdate);
  let Start_Hour = this.state.time &amp;&amp; this.state.time.format(formatHour);
  let End_Day = this.state.endDate &amp;&amp; this.state.endDate.format(Formatdate);
  let End_Hour = this.state.timeEnd &amp;&amp; this.state.timeEnd.format(formatHour);
  let diff = this.state.timeEnd - this.state.startDate;
  console.log(diff);}
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/XMAUi.jpg" alt="The error"></p>
  
  <p>The code for the first DatePicker and the TimePicker ( for the start )</p>
  
  <pre><code>&lt;DatePicker
    id="calendar"
    className="TestIcon"
    dateFormat='YYYY-MM-DD'
    placeholderText="Date de fin"
    selected={this.state.startDate}
    onChange={this.handleChangeStart}/&gt;
  
  &lt;TimePicker showSecond={false}
       placeholder={time}
       onChange={this.onChangeStart}&gt; &lt;/TimePicker&gt;
  </code></pre>
  
  <p>The code for the second dataPicker and TimePicker</p>
  
  <pre><code>&lt;DatePicker
      id="calendar"
      className="TestIcon"
      dateFormat='YYYY-MM-DD'
      selected={this.state.endDate}
      onChange={this.handleChangeEnd}/&gt;
  
   &lt;TimePicker showSecond={false}
    placeholder={timeEnd}
    onChange={this.onChangeEnd}&gt; &lt;/TimePicker&gt;
  </code></pre>