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

  1. Choose the text, counts, explicit reference time or format parameters requested by this tool. Follow the stated byte, epoch-time and randomness assumptions.
  2. Enter now, epoch, step using the field table and calculation rules, then run the tool.
  3. Read counter, remainingSeconds. The explanation below defines the units, signs, ordering and any flags or placeholder values.
  4. 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 fieldMeaningValue type; see rules belowRequirement
nowReference epoch secondsinteger; minimum: 0; maximum: 9007199254740991Required
epochStep origin epoch secondsinteger; minimum: 0; maximum: 9007199254740991Required
stepTime-step secondsinteger; minimum: 1; maximum: 9007199254740991Required

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 fieldMeaningValue type
counterExact moving counterstring
remainingSecondsWhole seconds until next stepinteger; minimum: 1; maximum: 9007199254740991
json
{
  "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

  1. TOTP Step Remaining Seconds — tool.io

  2. 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.

Don't forget to set a bookmark for tool.io!
Privacy | Imprint | Cookies