Closed oorabi closed 8 years ago
This is expected behaviour, although it looks weird it is a consequence of months having different numbers of days. See this comment for more details, and if you can propose a better way of handling it please submit a patch.
Regardless of the Hours,Minutes, and Seconds, When i tried to get the difference between today "2016-05-22" and "2016-01-30", it was "3M 22 D". Also, the difference between "2016-05-22" and "2016-01-31", it was "3M 22D". But it is wrong as it should be one day difference between both results.
var moment = require('moment'); require('moment-precise-range-plugin'); var m1 = moment(); var m2 = moment('2016-01-31'); console.log(moment.preciseDiff(m1, m2)); Output: "3 months 22 days 8 hours 7 minutes 15 seconds"
var moment = require('moment'); require('moment-precise-range-plugin'); var m1 = moment(); var m2 = moment('2016-01-30'); console.log(moment.preciseDiff(m1, m2)); "3 months 22 days 8 hours 9 minutes 37 seconds"