title: calculating hours between two dates and time in javascript
body: <p>I am trying to calculate total hours and minute different two different date and time:</p>
  <p>below is my code:</p>
  <pre><code>let startShiftTime = moment(StartTime, ['DD-MM-YYYY h:mm:ss A'])
      .utcOffset(0, false)
      .format('DD-MM-YYYY hh:mm:ss A');
  
  let endShiftTime = moment(EndTime, ['DD-MM-YYYY h:mm:ss A'])
      .utcOffset(0, false)
      .format('DD-MM-YYYY hh:mm:ss A');
  
  var TotalSeconds = moment(startShiftTime, 'DD-MM-YYYY hh:mm:ss A')
      .utcOffset(0, false)
      .diff(
          moment(endShiftTime, 'DD-MM-YYYY hh:mm:ss A').utcOffset(0, false),
          'seconds',
      );
  
  var hours = Math.floor(TotalSeconds / 3600);
  var minutes = Math.floor((TotalSeconds / 60) % 60);
  console.log(
      'startShiftTime: ',
      startShiftTime,
      ' endShiftTime: ',
      endShiftTime,
      ' hours: ',
      hours,
      ' minutes: ',
      minutes,
  );
  </code></pre>
  <p>I am getting hours and minutes in all cases apart from case time difference is 1 hours or else</p>
  <p>console output:</p>
  <pre><code>startShiftTime:  02-12-2021 09:00:00 AM  endShiftTime:  01-12-2021 09:30:00 PM  hours:  11  minutes:  30
  startShiftTime:  02-12-2021 04:30:00 PM  endShiftTime:  02-12-2021 05:00:00 PM  hours:  -1  minutes:  -30
  </code></pre>
  <p>see in the second output... time difference is only 30 mins.. but in hours I am getting as 1</p>
  <p>I am not able to understand where I am making mistake</p>