getAgo()function

getAgo(target: PossibleDate, current: PossibleDate = "now", caller: AnyCaller = getAgo): DurationData
ParamType
targetPossibleDate
Date the duration counts back from. required
currentPossibleDate
Date the duration counts to (defaults to now). Defaults to "now"
callerAnyCaller
Function to attribute a thrown error to (defaults to getAgo itself). Defaults to getAgo
Return
DurationData
DurationData object for the span from target to current.
Throws
RequiredError
If target or current cannot be converted to a valid date.

Get the various time units since a certain date.

Examples

getAgo("2000-01-01") // { years: 26, ... }