0
var firstDate=moment('Sat Jul 30 2016 00:00:00 GMT+0530 (India Standard Time)');
var secondDate=moment('Fri Jul 29 2016 10:56:39 GMT+0530 (India Standard Time)');

console.log(firstDate.diff(secondDate,'days'));

Expected Output: 1

Actual Output: -0

Any reason why this is happening?

Apostolos
  • 10,033
  • 5
  • 24
  • 39
Prakash Gupta
  • 203
  • 1
  • 4
  • 13

1 Answers1

1

Pass the second argument as true to diff method to prevent moment from rounding the difference to nearest zero.

firstDate.diff(secondDate,'days', true)
Girish
  • 51
  • 1
  • 2