getSecondsUntil()function

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

Count the whole seconds until a date.

  • Rounds to the nearest whole second, i.e. 1 second 499 ms returns 1

Examples

getSecondsUntil(target) // 90