TOTP Step Remaining Seconds
Calculate the TOTP moving counter and whole seconds remaining in its current time step from explicit epoch seconds.
Description
TOTP divides elapsed epoch time into fixed-duration steps, each assigned a moving counter.
TOTP divides elapsed epoch time into fixed-duration steps, each assigned a moving counter. At a step boundary a new interval begins, so its remaining duration is the full step rather than zero.1, 2
Calculate the TOTP moving counter and whole seconds remaining in its current time step from explicit epoch seconds.
When to use TOTP Step Remaining Seconds
Use this tool to calculate the TOTP moving counter and whole seconds remaining in its current time step from explicit epoch seconds.
Choose the text, counts, explicit reference time or format parameters requested by this tool. Follow the stated byte, epoch-time and randomness assumptions.
How to use TOTP Step Remaining Seconds and understand its results
- Choose the text, counts, explicit reference time or format parameters requested by this tool. Follow the stated byte, epoch-time and randomness assumptions.
- Enter now, epoch, step using the field table and calculation rules, then run the tool.
- Read counter, remainingSeconds. The explanation below defines the units, signs, ordering and any flags or placeholder values.
- If the tool reports an input issue, correct the values and run it again. Apply the stated assumptions when interpreting a successfully returned result.
| Input field | Meaning | Value type; see rules below | Requirement |
|---|---|---|---|
| now | Reference epoch seconds | integer; minimum: 0; maximum: 9007199254740991 | Required |
| epoch | Step origin epoch seconds | integer; minimum: 0; maximum: 9007199254740991 | Required |
| step | Time-step seconds | integer; minimum: 1; maximum: 9007199254740991 | Required |
Enter nonnegative safe-integer now and epoch values in seconds and a positive integer step in seconds. now must not precede epoch. Exact integer subtraction/division computes the counter and remainder; counter is returned as a decimal string and remainingSeconds as an integer. At exact boundaries the remaining value equals step.
counter = floor((now − epoch)/step); remainingSeconds = step − ((now − epoch) mod step) Units, indexing, boundary conditions and exceptional cases are defined in the calculation rules above.
| Output field | Meaning | Value type |
|---|---|---|
| counter | Exact moving counter | string |
| remainingSeconds | Whole seconds until next step | integer; minimum: 1; maximum: 9007199254740991 |
{
"input": {
"now": 59,
"epoch": 0,
"step": 30
},
"output": {
"counter": "1",
"remainingSeconds": 1
}
} Limitations and assumptions
This does not generate or verify an OTP, use a secret or read the current clock. Milliseconds must be converted before entry. Acceptance windows, clock skew and fractional seconds are not modeled; use the explicit reference time consistently.
Numeric inputs must be finite. Follow the calculation-specific rules for overflow, underflow and exceptional cases. Missing required fields, extra fields, wrong value types and violations of the calculation rules are input errors.
Alternative or Complementary methods
Use JWT exp Days-Left Converter: Convert a supplied JWT exp NumericDate and reference NumericDate into signed fractional days remaining and expiry status. For a complementary task, use Certificate Validity Days Left: Classify an explicitly supplied certificate validity interval and calculate fractional days until notAfter using epoch milliseconds.
Further background: RFC 6238: TOTP time-step counter.
References
-
TOTP Step Remaining Seconds — tool.io
-
RFC 6238: TOTP time-step counter — RFC Editor
Similar or alternative tools
- JWT exp Days-Left Converter
Convert a supplied JWT exp NumericDate and reference NumericDate into signed fractional days remaining and expiry status.
- Certificate Validity Days Left
Classify an explicitly supplied certificate validity interval and calculate fractional days until notAfter using epoch milliseconds.