Skip to content

Timestamps: seconds vs milliseconds (spot and fix it)

Practical guide: digit rule, real examples, timezone, pitfalls, and tips to avoid expensive bugs.

← Guides
Updated: 2026-03-22

How to use this guide well

These guides are more useful when you read them as operational help, not as filler documentation.

Start from the section that matches the failure

Do not read linearly if you do not need to. Jump to the section that looks closest to the incident, payload, or config you are debugging.

Copy only after you understand the constraint

The useful part is usually in the caveat, not in the snippet itself: timezone, dialect, schema, audience, type inference, or portability.

Then validate with the tool

Once the reasoning is clear, use the related tool to inspect the real value, payload, or expression instead of working from memory.

What you will find in this guide

A quick scan before you dive in.

Sections

3

Code examples

1

Related topics

dates, backend, frontend

Apply this guide in 3 steps

A short workflow tuned to the type of issue this guide covers.

Identify the unit before converting

Decide whether the source value is in seconds or milliseconds before reading any formatted date.

Compare systems, not screenshots

Check client, server, logs, and database timestamps side by side so timezone or locale differences become obvious.

Reproduce the boundary case

Test the exact timestamp that breaks sorting, expiry, scheduling, or auth instead of sampling with a nearby value.

Quick rule

10 digits ≈ seconds, 13 digits ≈ milliseconds. 1970 or year 51382 usually means wrong units.

Real example

Frontend treating seconds as milliseconds.

ts
const expSeconds = 1893456000
new Date(expSeconds)        // wrong
new Date(expSeconds * 1000) // correct

FAQ

JS Date uses ms. JWT exp uses seconds. Normalize units internally.

Related tools

Use the matching tool when you want to validate or reproduce the issue described in this guide.

Keep exploring this topic

Move between deep guides and shorter task-focused articles so the site works like a connected knowledge base, not a dead end.