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

Date.diff

$date.diff($fromDate='now', $unit='seconds') -> number

Description

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

$fromDate can be one of the following:

$fromDate 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 (seconds)

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

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

See Also