Encrypt Online
Theme

Certificates & Site Ops

Milliseconds vs Seconds vs Microseconds in Logs

A practical timestamp debugging guide for spotting unit mistakes quickly when values in logs or APIs look almost right.

Encrypt Online Editorial Team3 min read
Encrypt Online guide cover on a sand background with the headline "Seconds or milliseconds?". One ordinary clock represents Unix time; the ISO converter uses an unboxed ISO identity. Marker: s.

The one-unit bug is one of the most common time bugs because the number still looks plausible. It is just off by three or six zeroes, which is enough to throw tokens, TTLs, and log analysis into chaos.

The good news is that unit bugs are usually easy to detect once you stop reading the number as a mystery and start reading its magnitude.

In brief

What it is: Epoch values can be expressed in seconds, milliseconds, or microseconds, and the unit must be known before the number can be interpreted correctly.

Why it matters: A unit mismatch can shift a timestamp by decades or collapse a valid window into immediate expiry.

Worth knowing: Because the number often looks realistic, people sometimes debug the wrong layer before checking the unit.

Magnitude is your first clue

A ten-digit Unix value often suggests seconds for modern dates. Thirteen digits often suggests milliseconds. Sixteen digits often points to microseconds. Treat this as a fast first screen, then confirm the unit against the system contract.

Once you suspect the unit, convert it immediately instead of continuing to reason in raw numbers.

Unit bugs spread across layers

Normalize timestamp units across frontends, backends, JWT libraries, logs, databases, and API contracts.

  • Count digits before discussing meaning.
  • Normalize the unit before comparing across systems.
  • Document the unit in the contract instead of leaving it implicit.

Why a tiny converter is so useful

A timestamp converter earns its place by turning suspicion into confirmation quickly. When the same value is shown as seconds, milliseconds, and human-readable time side by side, the bug often resolves itself.

See it in a small example

Notice: Use this quick heuristic to form a guess, then confirm it against the actual system contract.

Text
10 digits -> usually seconds
13 digits -> usually milliseconds
16 digits -> often microseconds

What to verify

  • Count digits before doing anything else.
  • Normalize the value into one explicit unit across systems.
  • Write the unit into the API or log contract so the next person does not guess.

Common questions

Are digit counts always enough to know the unit?

No, but they are an excellent first clue for modern timestamps.

Can a unit bug break JWT validation?

Yes. Time-window claims are extremely sensitive to unit mistakes.

References