incorrect number of months can occure
Take two dates: 28 Feb 2015 and 28 Mar 2015.
Correct diff should be 1 month. Current datediff() implementation returns 0 months, 28 days:
{"years":0,"months":0,"days":28,"hours":0,"minutes":0,"seconds":0}
Although I find this solution quite elegant, it is not really accurate.
upd. I wrote another implementation of date difference that solves the issue.
@sergiks thanks for this notice. I think, that's correct difference between those two dates, it could be one month or 28 days. http://www.calculator.net/date-calculator.html?today=02%2F28%2F2015&ageat=03%2F28%2F2015&calctype=diff&x=63&y=13
@dmfilipenko I agree on that. Another example, Feb 15 to Mar 17:
JSON.stringify( datediff( new Date(2016,01,15,12,0,0), new Date(2016,02,17,12,0,0)))
I'd expect that to be 1 month, 2 days. But as current solution transposes the interval back to Jan 1, the result is 1 month 0 days (because there's 31 day in January).