getSecondsUntil()function
getSecondsUntil(target: PossibleDate, current?: PossibleDate, caller: AnyCaller = getSecondsUntil): number
| Param | Type | |
|---|---|---|
target | PossibleDate | Date to count up to. required |
current | PossibleDate | Date to count from (defaults to now). |
caller | AnyCaller | 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 msreturns1
Examples
getSecondsUntil(target) // 90