new DateTime().diff(DateTime|String|Number|Date|Array);
new DateTime().diff(DateTime|String|Number|Date|Array, String);
new DateTime().diff(DateTime|String|Number|Date|Array, String, Boolean);
To get the difference in milliseconds, use `DateTime#diff` like you would use `DateTime#from`.
var a = new DateTime(2007, 0, 29);
var b = new DateTime(2007, 0, 28);
a.diff(b)
To get the difference in another unit of measurement, pass that measurement as the second argument.
var a = new DateTime(2007, 0, 29);
var b = new DateTime(2007, 0, 28);
a.diff(b, 'days')
The supported measurements are `years`, `months`, `weeks`, `days`, `hours`, `minutes`, and `seconds`. For ease of development,the singular forms are supported. Units of measurement other than milliseconds are available. By default, `DateTime#diff`
will truncate the result to zero decimal places, returning an integer. If you want a floating point number, pass`true` as the third argument.
var a = new DateTime(2008, 9);
var b = new DateTime(2007, 0);
a.diff(b, 'years');
a.diff(b, 'years', true);
If the DateTime is earlier than the DateTime you are passing to `DateTime.fn.diff`, the return value will be negative.
var a = new DateTime();
var b = new DateTime().add(1, 'seconds');
a.diff(b) b.diff(a)
An easy way to think of this is by replacing `.diff(` with a minus operator.
a.diff(b)
b.diff(a)
Month and year diffs
`DateTime#diff` has some special handling for month and year diffs. It is optimized to ensure that two months with the same date are always a whole number apart. So Jan 15 to Feb 15 should be exactly 1 month. Feb 28 to Mar 28 should be exactly 1 month.
Feb 28 2011 to Feb 28 2012 should be exactly 1 year.