getHoursAgo()function

getHoursAgo(target: PossibleDate, current?: PossibleDate, caller: AnyCaller = getHoursAgo): number
ParamType
targetPossibleDate
Date to count back from. required
currentPossibleDate
Date to count to (defaults to now).
callerAnyCaller
Function to attribute a thrown error to (defaults to getHoursAgo itself). Defaults to getHoursAgo
Return
number
Number of whole hours from target to current (negative if target is in the future).
Throws
RequiredError
If target or current cannot be converted to a valid date.

Count the whole hours since a date.

  • Rounds to the nearest whole hour, i.e. 1 hour 29 minutes returns 1

Examples

getHoursAgo(target) // 3