getMinutesAgo()function

getMinutesAgo(target: PossibleDate, current?: PossibleDate, caller: AnyCaller = getMinutesAgo): 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 getMinutesAgo itself). Defaults to getMinutesAgo
Return
number
Number of whole minutes 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 minutes since a date.

  • Rounds to the nearest whole minute, i.e. 1 min 29 seconds returns 1

Examples

getMinutesAgo(target) // 5