Skip to tool
ecech.
🕑 Date, Time & Timezone

Timestamp Unit Detector, Because a Wrong Guess Still Gives a Valid Date

1000000000 is September 2001 in seconds and January 1970 in milliseconds. Both parse, so validity cannot decide it. Here is every reading at once.

Every reading

Digit count is the practical rule

10 digitsseconds1786000000
13 digitsmilliseconds1786000000000
16 digitsmicroseconds1786000000000000
19 digitsnanoseconds1786000000000000000
Advertisement

How the calculation works

Why "try it and see if the date is sensible" fails 1000000000 read as seconds 9 September 2001 a completely plausible date read as milliseconds 12 January 1970 also a completely valid date Both parse. Neither errors. The unit has to come from the digit count or the source.

How to Use This Tool

Paste the number. Every interpretation is shown at once, ranked by which is most likely given the digit count, so you can pick the one that lands where you expect.

Why digit count works

Each step up in precision multiplies the number by a thousand, which adds three digits. Since we are currently around 1.7 billion seconds since 1970, the eras are far enough apart that the length of the number is almost always decisive: ten digits is seconds, thirteen is milliseconds, sixteen is microseconds, nineteen is nanoseconds.

This rule holds for any date from roughly 2001 to 2286 in seconds, which covers essentially every timestamp you will meet in a running system. It breaks for dates far in the past — a 1970s timestamp in seconds has only nine digits or fewer — which is exactly when you should look at the source rather than the number.

Why you cannot just check whether the date is valid

This is the part people get wrong. A common approach is to try both and keep whichever gives a sensible date. But 1000000000 is September 2001 as seconds and January 1970 as milliseconds, and both are real dates that parse without error. Nothing throws. If your data happens to contain old records, the wrong reading can look entirely reasonable and you will not notice.

The same problem appears in reverse: a millisecond timestamp read as seconds lands about fifty thousand years in the future, which is obviously wrong — so that direction is usually caught, and the other direction is not. Asymmetric failure modes are the ones that reach production.

One direction is obvious, the other is not milliseconds read as seconds year 58,000-ish someone notices seconds read as milliseconds a date in 1970 looks like old data A wrong date that looks like a plausible old record is the one that survives review.
The failure that looks like normal data is the expensive one.

Where each unit comes from

  • Seconds — Unix time(), most APIs, JWT exp and iat claims, Postgres extract(epoch ...).
  • Milliseconds — JavaScript Date.now(), Java System.currentTimeMillis(), most JSON produced by those languages.
  • Microseconds — Python datetime internals, some database timestamp columns, Chrome tracing.
  • Nanoseconds — Go's UnixNano, Prometheus and other metrics systems, high-resolution profilers.

A mixed pipeline containing two of these is where the confusion usually starts. If you control the format, storing seconds with an explicit unit in the field name — created_at_ms rather than created_at — removes the guesswork permanently.

Advertisement

Frequently Asked Questions

How do I know if a timestamp is in seconds or milliseconds?
Count the digits. Ten digits is seconds, thirteen is milliseconds, sixteen is microseconds and nineteen is nanoseconds, for any date in the current era. This works because each step in precision multiplies by a thousand, adding three digits, and the resulting ranges do not overlap for present-day dates.
Why can't I just try both and see which date looks right?
Because both often produce valid dates. 1000000000 is September 2001 read as seconds and January 1970 read as milliseconds — neither errors. If your data contains genuinely old records, the wrong reading can pass as plausible, which is exactly how the mistake survives review.
What is a 13-digit timestamp?
Milliseconds since 1 January 1970. It is what JavaScript's Date.now() and Java's System.currentTimeMillis() return, so it appears in most JSON produced by those languages. Divide by 1000 to get seconds, which is what most APIs and Unix tools expect.
Why did my date come out in 1970?
Almost certainly because a seconds value was interpreted as milliseconds, making it a thousand times smaller and landing it a few days after the epoch. The reverse mistake pushes the date tens of thousands of years into the future, which people usually catch — this direction is the quiet one.
What produces microsecond and nanosecond timestamps?
Microseconds come from Python's datetime internals, some database timestamp columns and Chrome tracing. Nanoseconds come from Go's UnixNano, Prometheus and high-resolution profilers. Both lose precision if they pass through a JavaScript Date, which only holds milliseconds.
How do I stop this confusion happening again?
Put the unit in the field name. A field called created_at_ms is unambiguous to everyone who reads it later, including you; created_at is a guess that each consumer makes independently. If you also control the wire format, an ISO 8601 string with an offset removes the question entirely.

Related tools in Date, Time & Timezone

Browse all Date, Time & Timezone tools
The desk where ecech. tools get written: a laptop, a notebook of to-dos and a whiteboard listing the tools on the site.

Made by one person

ecech. is not a content farm. Every tool here is written and checked by hand, one at a time, by someone who wanted the tool to exist and could not find a version that showed its working.

No accounts and no sign-in, and nothing you type reaches a server — every calculation on this page runs inside your browser. The ads are served by Google and do set their own cookies, which is set out in full on the privacy page. More about the site.