Epoch Millis vs Seconds Detector
After reading this you will be able to look at a bare number like 1700000000000 and know without a lookup table whether it counts seconds, milliseconds, microseconds or nanoseconds since 1970, and why the digit count decides the answer.
What the detector does and one example
A Unix timestamp is a single integer: the number of time units elapsed since 1970-01-01T00:00:00Z, called the epoch. The trouble is that the integer carries no unit. The number 1700000000 and the number 1700000000000 both name a moment in November 2023, but one counts seconds and the other counts milliseconds. Off by a factor of 1000, and nothing in the digits announces which.
The detector takes your number and tries all four common units. It divides by the right power of 10 to get seconds, converts each candidate to a human date, then reports which interpretation lands in a sane range (roughly the years 2001 to 2286). That range is where real production timestamps almost always sit, so exactly one candidate usually survives.
Take 1700000000. Read as seconds it is 2023-11-14T22:13:20Z. Read as milliseconds it is 1970-01-20T16:13:20Z, which is 19 days after the epoch and almost certainly wrong. So the detector calls it seconds. Add three zeros and the verdict flips.
When to reach for it, and when not
Use the detector when a number arrives with no schema attached: a value in a log line, a column in a CSV export, a field in an API response whose docs are silent, a cookie value, a JWT exp claim you copied out of context. In all of these the unit is implicit and you need to recover it.
You do not need it when the source already tells you the unit. JavaScript's Date.now() returns milliseconds, always. The C time() call and most SQL UNIX_TIMESTAMP() functions return seconds. Postgres extract(epoch from ...) returns seconds as a float. When you control both ends, read the docs instead of guessing.
The detector guesses from magnitude, not from meaning. It cannot tell a real timestamp from a random 13 digit ID that happens to fall in 2023. If a number decodes to a plausible date but the field is named order_id, trust the field name.
The math behind the digit count
Every unit is seconds scaled by a power of 10. One second is 1000 milliseconds, 1,000,000 microseconds, 1,000,000,000 nanoseconds. To convert a raw count n in a given unit back to seconds, divide by the scale factor:
Here n is your raw integer, s is the scale for the unit under test (1 for seconds, 1000 for millis, and so on), and t_{\text{sec}} is seconds since the epoch that you then feed to a date function.
The digit count works because the seconds value for dates near now is itself about 10 digits long. A moment in 2023 is roughly 1.7 \times 10^9 seconds after the epoch. Take the base-10 logarithm to count digits:
d(n) is the number of decimal digits in n, and \lfloor \cdot \rfloor is the floor. Since seconds sit near 10 digits and each unit multiplies by another 10^3, millis land near 13 digits, micros near 16, nanos near 19. The gaps are three digits wide, so for any date in the next couple of centuries the interpretations do not overlap.
These boundaries are stable, not eternal. Seconds cross into 11 digits on 2286-11-20, when the count reaches 10000000000. Until then, 10 digits means seconds with no ambiguity.
Worked example: reproducing the demo
Decoding 1700000000000
Press the demo button and the tool loads 1700000000000, a 13 digit number. Follow the same steps the detector runs.
- Count digits:
1700000000000has 13 digits, which points at milliseconds. - Test as seconds: t = 1700000000000. That is about 5.4 \times 10^4 years after 1970, landing near the year 55880. Outside the plausible range, so rejected.
- Test as millis: t = 1700000000000 / 1000 = 1700000000 seconds. That is
2023-11-14T22:13:20Z. Inside the range, so accepted. - Test as micros: t = 1700000000000 / 10^6 = 1700000 seconds, which is
1970-01-20T16:13:20Z. Nineteen days after the epoch, so rejected. - Test as nanos: t = 1700000000000 / 10^9 = 1700 seconds, which is
1970-01-01T00:28:20Z. Rejected.
Exactly one candidate, milliseconds, produces a date in this century. That is the verdict.
Reading and interpreting the results
The tool shows the decoded date for every candidate, not only the winner, so you can override the guess when you know something it does not. Read the losing rows too. If milliseconds decodes to 2023-11-14 and seconds decodes to a year 55 millennia out, that lopsided spread is your confidence: the answer is not close.
Watch for the case where two candidates both look plausible. This happens with values around the boundaries. A number near 10000000000 (11 digits) is awkward: as seconds it is the year 2286, as millis it is 1970-04-26. Neither is obviously the intended date, so you must know the source.
- Epoch
- The reference instant
1970-01-01T00:00:00Zfrom which Unix time counts. Also called the Unix epoch. - Scale factor
- The power of 10 that converts a unit to seconds: 1, 1000, one million, one billion.
- Plausible range
- The date window (about 2001 to 2286) the detector treats as evidence that an interpretation is real.
Common mistakes
The most frequent bug is passing seconds to a millisecond API. new Date(1700000000) in JavaScript treats the argument as milliseconds, so it produces 1970-01-20, not 2023. The fix is new Date(1700000000 * 1000). If your dates cluster in January 1970, you are off by a factor of 1000 in this direction.
The mirror mistake is passing millis to a seconds API. Feed 1700000000000 to a function expecting seconds and you get a date around the year 55880, which most libraries clamp, wrap or reject.
A third trap: fractional seconds. Some systems emit seconds as a float, like 1700000000.123. That is not milliseconds and does not become 13 digits. Strip or keep the decimal on purpose, and do not multiply a float that already carries sub-second precision.
When you store timestamps, write the unit into the column name or the key: created_at_ms, expires_at_sec. A four character suffix removes every guess downstream and makes the detector unnecessary for your own data.
See it move
The single idea worth touching yourself is how the same instant shifts across four digit bands as you change the year. Drag the year and watch each unit's digit count and decoded validity change together.
Related tools
Once the detector tells you the unit, convert the value to a readable date and timezone with the Unix Timestamp Converter. If your timestamps come from a scheduler, the Cron Expression Parser explains any cron line and previews its next runs. And when a 13 digit number turns out to be an identifier rather than a time, the UUID / ULID / Nano ID Generator produces sortable IDs (ULID and UUID v7) that embed a real millisecond timestamp on purpose.
Frequently asked questions
How do I know if a number is seconds or milliseconds?
Count the digits. For any date between 2001 and 2286, 10 digits is seconds, 13 is milliseconds, 16 is microseconds, 19 is nanoseconds. The number 1700000000 (10 digits) is seconds; 1700000000000 (13 digits) is milliseconds.
Why does my timestamp show a date in 1970?
You almost certainly passed seconds to a function that expects milliseconds. A 10 digit seconds value read as millis lands about 20 days after the epoch. Multiply by 1000 before passing it in.
Can two units both look valid for the same number?
Yes, near the boundaries. An 11 digit number like 10000000000 is the year 2286 as seconds and April 1970 as millis. When both are defensible, the digit count cannot settle it and you need the source's documentation.
Do these digit rules ever expire?
The seconds count crosses from 10 to 11 digits on 2286-11-20. Before then the four bands never overlap for real dates. After then the seconds band shifts up by one digit, so the shortcut needs adjusting.
Is anything I paste sent to a server?
No. The detector runs entirely in your browser, so the number you paste never leaves your device.