Converting a Unix timestamp sounds like a one-second task: paste a number, get a date, move on. Yet most timestamp bugs in production do not come from hard math. They come from skipping one quiet decision: which unit is this number in, and which clock am I reading it against? When that decision is made by intuition — "ten digits, must be seconds" — conversion becomes guesswork, and guesswork does not survive contact with real data.
The fix is not a better formula. It is a repeatable process: three steps, performed in the same order every time, with a built-in check that catches mistakes before they ship. This guide walks through that process using the Timestamp Explorer, then covers the edge cases that make it trustworthy.
Why "infer from digit count" fails
The popular heuristic says a 10-digit number is seconds and a 13-digit number is milliseconds. A heuristic that is right 95% of the time trains you to stop thinking, then quietly hands you the other 5%:
- Dates before 2001. Seconds values for the 1990s have only 9 digits. An old legacy record looks "too short," and someone "fixes" it by treating it as milliseconds — producing a date in 1970.
- Far-future timestamps. Milliseconds past 2286 reach 14 digits; seconds past the same era reach 11. Systems projecting dates decades ahead produce numbers whose length defies the table you memorized.
- Trailing zeros. A seconds value of
170000000(March 1975) is also 9 digits. Length cannot distinguish a truncated value from a genuinely old one.
The deeper issue: digit count is a property of the number, not of its meaning. The unit is a fact about the system that produced the number — the API contract, the database column type, the log format spec. That fact is written down somewhere; find it instead of counting characters.
Step 1: Name the unit — never infer it
Before you convert anything, state the unit out loud (or in a comment): seconds or milliseconds. Get it from the source, in this order of authority:
- The documentation or spec. API references for payment providers, messaging platforms, and cloud services almost always state the unit explicitly. If the docs say "epoch milliseconds," step 1 is done.
- The producer's code. Look for
Date.now()orSystem.currentTimeMillis()(milliseconds) versustime(),Math.floor(Date.now() / 1000), or Go'sUnix()(seconds). - The storage schema. A
BIGINTcolumn namedcreated_at_mstells you everything. A PostgresTIMESTAMPstores microseconds internally — a third unit that surprises people who assumed seconds. - Plausibility against known context. Last resort only: check which unit produces a date matching known context. A hypothesis to confirm, not an inference to trust.
Write the decision down. "1700000000 (seconds)" in a bug report is unambiguous; a bare number traps the next reader.
Step 2: Name the zone
A timestamp has no timezone. 1700000000 is a count of seconds from a fixed instant — it means the same thing in Tokyo and Toronto. Timezone only enters when you display that instant as a human-readable date. So step 2 is choosing which rendering you need:
- UTC — for logs, storage, API payloads, and anything a machine reads back later. UTC rendering is stable: the same instant always prints the same string, so the log line's UTC date is the ground truth when debugging.
- Browser local time — for answering "when did this happen for the user." A ticket saying "the charge appeared at 2 AM" only makes sense in the user's timezone, daylight saving quirks included.
Name the zone before converting for the same reason you name the unit: it turns an implicit assumption into a stated fact. Most "off by several hours" reports are not conversion errors at all — they are two people reading the same instant in different zones and assuming disagreement means error. (We cover the unit half of this confusion in a dedicated guide on seconds vs. milliseconds.)
Step 3: Read the same instant from both sides
The first two steps set up the conversion. The third step makes the process self-verifying: convert in both directions and confirm the results agree.
- Forward: timestamp → date. Paste
1700000000, read the resulting date string. - Backward: date → timestamp. Take that same date string, convert it back, and confirm you get
1700000000again.
If the round trip returns your original number, the unit and zone you named are consistent. If it does not — if 1700000000 becomes November 14, 2023 forward but produces 1699999200 backward — an assumption is wrong: the zone for the backward leg does not match the forward leg, or the unit was misidentified.
Forward: 1700000000 s → 2023-11-14T22:13:20Z
Backward: 2023-11-14T22:13:20Z → 1700000000 s
Match: yes → unit and zone are consistent
One direction gives you an answer; both directions give you an answer you can defend.
Walkthrough: the same process in Timestamp Explorer
The Timestamp Explorer is built around exactly these three steps, so the walkthrough rehearses the process itself.
1. Set the unit explicitly
Before touching the input, select the unit toggle — Seconds or Milliseconds. Do not rely on auto-detection. If you are converting a value from a payment webhook whose docs say "Unix timestamp in seconds," set Seconds and move on. The toggle exists so the unit is a visible choice, not an invisible default.
2. Paste the value and read both lines
Enter 1700000000 with Seconds selected. The tool displays two date renderings of the same instant:
Input: 1700000000 (seconds)
ISO line: 2023-11-14T22:13:20Z ← UTC, for logs and storage
Local line: Tue, Nov 14 2023, 22:13 ← your browser's zone, for "when for me"
Check both lines against your answer to step 2. Debugging a log entry? Compare the ISO line against the log. Answering a user-facing question? Quote the local line — after confirming that your zone matches the user's, or accounting for the difference.
3. Flip the unit and observe the failure mode
Now — and this is the instructive part — switch the toggle to Milliseconds while the input is still 1700000000. The date re-renders as something like January 18, 1970: interpreting a seconds value as milliseconds divides your instant by 1000, landing you near the epoch.
Notice what this failure looks like: not a subtle "a few hours off" error that could pass a casual glance, but a date five decades in the past — obviously wrong, impossible to mistake for plausible. The reverse mistake is equally loud: a 13-digit millisecond value read as seconds produces a date roughly 31,000 years in the future.
This is the quiet gift of timestamps: unit errors produce loud failures. Dates near the epoch or far in the future should trigger an immediate "wrong unit" reflex. The dangerous errors are zone errors, which are small enough to look like rounding and get blamed on timezones that were never the problem. Train yourself: huge date → check unit; slightly-off date → check zone.
4. Round-trip check with the current time
For a final sanity check on the tool (or on any new conversion code), use now as the input, because you already know the answer:
1. Convert "now" → timestamp. Result: 1787412345 (seconds)
2. Convert 1787412345 back → date. Must equal the current instant.
3. Repeat with Milliseconds selected. Result: 1787412345000 (ms)
If the round trip matches in both units, your process and your tool agree with reality. If not, stop and find out why before converting anything that matters — the mismatch will be there for your production data too. Run it whenever you touch unfamiliar conversion code or a data source with undocumented units. It takes ten seconds and catches mistakes that otherwise surface at 3 AM.
Fractional seconds: why silent rounding is the enemy
Real timestamps occasionally arrive with a fractional part — 1700000000.5 means "half a second after that instant," commonly produced by high-resolution logging or Python's time.time(). The Timestamp Explorer accepts decimal seconds to three places (milliseconds):
Input: 1700000000.5
Reads as 1700000000 seconds + 500 milliseconds
ISO line: 2023-11-14T22:13:20.500Z
What it does not accept is a milliseconds value written as a fraction — 1700000000000.25 gets rejected, because a quarter of a millisecond cannot be represented and pretending otherwise would require rounding.
That rejection is deliberate. Silent rounding is the enemy of a repeatable process because it breaks the round trip. If a tool accepts 1700000000000.25 and quietly returns ...500Z, your backward check can still "match" while the underlying value has changed. Nothing failed, nothing warned, and yet the number you started with is not the number you ended with — and in systems that compare timestamps for ordering, a silently rounded millisecond can reorder events.
An explicit error beats a plausible wrong answer every time. This is the same philosophy behind structured error responses in APIs: when an input cannot be honored, say so precisely rather than returning something close. (For the API-design side of that principle, see the guide on Problem Details errors; for how timestamps behave in API metadata and headers, see JSON in HTTP headers.)
The process, summarized
Here is the whole method — what goes in, what comes out, and what you checked at each step:
| Step | Input | Output |
|---|---|---|
| 1. Name the unit | Docs, producer code, or storage schema for the value | A stated fact: "seconds" or "milliseconds" |
| 2. Name the zone | The question you are answering (log debugging vs. user-facing) | A stated rendering target: UTC or a specific local zone |
| 3a. Forward convert | Timestamp + named unit, set explicitly in the tool | ISO line (UTC) and local line, both read and compared |
| 3b. Backward convert | The date string from step 3a | A timestamp that must equal the original input |
| Sanity check (optional but cheap) | The current time | A round trip that matches in both units |
A pocket checklist
Tape this to your team's on-call doc:
- Unit named? Seconds or milliseconds, stated from documentation — never inferred from digit count.
- Zone named? UTC for anything a machine reads back; local time only for "when for the user."
- Unit set explicitly? In the tool toggle, in your code — visible, not assumed.
- Both lines read? ISO (UTC) and local — pick the one that matches the question, not the one that looks right.
- Round trip closed? Date → timestamp → date returns the original value. If not, stop.
- Date plausible? Near 1970 or thousands of years out → wrong unit. A few hours off → wrong zone.
- Fractions handled? Decimal seconds to 3 places fine; fractional milliseconds rejected, and nothing rounded silently.
None of these steps is difficult. The value is in doing them in the same order, every time, so conversion stops being a small gamble each time you meet a new number — and becomes a process that catches its own mistakes.
Reproduce every example locally with the JSON Inspector or the matching tool on the workbench. Nothing you paste leaves your browser.