Version: v0.7.1 - Beta.  We welcome contributors & feedback.

Date.diff

$date.diff($referenceDate = 'now', $unit = 'secs') -> number

Description

Return the duration of time between the Date object and $referenceDate.

$referenceDate can be one of the following:

$referenceDate is the point of reference, to determine if this date object comes before (negative) or after (positive).

$now = Date.now()

$futureDate = $now.add('2 hours')
$pastDate = $now.add('-1 hour')

$futureDate.diff()
//= 7200 (secs)

$pastDate.diff($futureDate, 'hours')
//= 3

$futureDate.diff($pastDate, 'hours')
//= -3

See Also