A timestamp arrives in a bug report and you convert it, and the date that comes back is in January 1970. Or in the year 55840. The number was fine. The moment it recorded was fine. What failed was a quieter assumption, made before any conversion happened: the unit the number counts in.

Unix timestamps come in two units, seconds and milliseconds, and the two forms of the same moment differ by a factor of a thousand. This guide shows how to tell which one you are holding, what each wrong guess produces, and how the Unix Timestamp Converter on Ovatly decides, so you can overrule it when you know better.

Contents

  • Quick answer
  • Two units, one moment
  • The digit test
  • How the converter decides
  • What goes wrong in each direction
  • The pre-2001 edge case
  • Step by step: checking a timestamp's unit
  • Limitations
  • Common mistakes
  • FAQs
  • Conclusion

Quick answer

Count the digits. Current timestamps in seconds have 10 digits; current timestamps in milliseconds have 13. If your number has 13 digits, it is almost certainly milliseconds. Paste it into the Unix Timestamp Converter on Auto-detect and it applies the same logic, treating values of 1 trillion or more as milliseconds and smaller values as seconds, and shows which unit it used. When a converted date lands in 1970 or tens of thousands of years in the future, the unit was guessed wrong.

Two units, one moment

A Unix timestamp counts the time since the Unix epoch: midnight at the start of 1 January 1970 in UTC. The classic form counts seconds. Many environments, JavaScript prominently, count milliseconds instead, for finer resolution. Neither is more correct; they are the same measurement kept at different precision.

The moment Tuesday, 14 November 2023 at 22:13:20 UTC makes the relationship concrete. In seconds it is 1700000000. In milliseconds it is 1700000000000. Same instant, same digits at the front, three extra zeros of precision at the end. Everything that goes wrong with units comes from treating one of those numbers as the other.

The digit test

Because a millisecond count is a thousand times larger, it is also longer, and length is a reliable field test for current values. A timestamp in seconds today has 10 digits. A timestamp in milliseconds today has 13. Before converting anything, count: ten digits points to seconds, thirteen points to milliseconds, and the converter's own FAQ uses exactly this test.

The test has one soft spot, covered below: it assumes a reasonably recent moment. Very old millisecond values are shorter than 13 digits, which is where the digit count stops being decisive and the unit selector takes over.

How the converter decides

Left on Auto-detect, the converter applies a threshold rule: values of 1 trillion or more are treated as milliseconds, and smaller values as seconds. It shows which unit it used, so the reading is never a silent guess; you can compare its choice against your own digit count and against whether the resulting date makes sense.

You are not obliged to accept the detection. The unit selector lets you force seconds or milliseconds when you know which form the source system produced. Forcing the unit is the right move whenever the source is known: a JavaScript Date.now() value is milliseconds by definition, a classic Unix time() value is seconds, and no threshold needs to arbitrate between facts you already have.

What goes wrong in each direction

Each wrong guess fails in its own recognisable direction, which makes diagnosis fast.

Read a seconds value as milliseconds and the date collapses toward the epoch. 1700000000, interpreted as milliseconds, is Tuesday, 20 January 1970 at 16:13:20 UTC. The whole of modern history compresses into the first weeks of 1970, because a thousand seconds-counts fit inside what the reader assumed was a single count of milliseconds. A converted date in 1970 is almost never a real 1970 event; it is a seconds value wearing the wrong unit.

Read a millisecond value as seconds and the date rockets forward. 1700000000000, interpreted as seconds, lands in the year 55840. The extra three digits, meant as sub-second precision, get read as roughly a thousand times more elapsed time. A converted date thousands of years ahead is the mirror-image symptom: a millisecond value wearing the wrong unit.

The pre-2001 edge case

Auto-detection has one honest weakness, and the converter's notes name it. A millisecond value from before 2001 is smaller than 1 trillion, so the threshold rule can misread it as seconds. Such a value has 12 digits, which already hints it fits neither modern pattern.

Take 929448000000, the millisecond timestamp for 15 June 1999 at 12:00 UTC. It sits below 1 trillion, so detection treats it as seconds, and the date lands in the year 31423. Nothing about the number is broken; the heuristic simply cannot see it. For historical timestamps, skip detection and force milliseconds with the unit selector.

Step by step: checking a timestamp's unit

  1. Count the digits of your value. Ten points to seconds, thirteen to milliseconds, twelve suggests an older millisecond value.
  2. Open the Unix Timestamp Converter and paste the value, or press Use current time to see a known-good value in both forms.
  3. Leave the unit on Auto-detect for a first reading, and note which unit the converter says it used.
  4. Read the UTC, ISO and local conversions and the relative description, and ask whether the date is plausible for the event you are investigating.
  5. If the date lands in 1970 or the far future, force the other unit with the selector and read again. The plausible date is the one the correct unit produces.

Limitations

The digit test and the threshold both key off the size of the number, so both inherit the same blind spot: millisecond values from before 2001, which are smaller than 1 trillion and can be misread as seconds. Detection is a strong default for current values, not a proof, and the converter says as much by showing its chosen unit and offering the selector. Separately, no unit choice rescues a value that is not a timestamp at all: values beyond the range JavaScript dates support, about 275,000 years either way, are reported as errors rather than rendered as dates.

Common mistakes

  • Converting before counting. The digit count takes two seconds and settles most unit questions before they become wrong dates.
  • Believing the 1970 result. A date within days of the epoch is the signature of a seconds value read as milliseconds, not a discovery about 1970.
  • Believing the far-future result. A date thousands of years ahead is a millisecond value read as seconds. Check the unit before reporting either.
  • Trusting auto-detection on historical data. Pre-2001 millisecond values fall below the threshold. Force the unit for old records.

FAQs

How can I tell if a timestamp is in seconds or milliseconds? Count the digits. Current timestamps in seconds have 10 digits; in milliseconds they have 13. If your number has 13 digits it is almost certainly milliseconds. The converter auto-detects the difference and shows which unit it used, so you can check its reading against your count.

What happens if I convert a millisecond timestamp as seconds? The date explodes into the far future. The millisecond value 1700000000000, read as seconds, lands in the year 55840. A converted date thousands of years ahead is the classic signature of a millisecond value that was treated as seconds.

What happens if I convert a seconds timestamp as milliseconds? The date collapses back to the start of 1970. The seconds value 1700000000, read as milliseconds, becomes Tuesday, 20 January 1970. A result within days of the epoch almost always means a seconds value was treated as milliseconds.

How does the converter decide which unit to use? On Auto-detect, values of 1 trillion or more are treated as milliseconds and smaller values as seconds, and the converter shows which unit it used. If you already know the unit, force seconds or milliseconds with the unit selector instead of relying on detection.

Can an old millisecond timestamp be misread? Yes. A millisecond value from before 2001 is smaller than 1 trillion, so auto-detection can read it as seconds and produce a date tens of thousands of years ahead. For historical values, set the unit selector to milliseconds rather than trusting the digit count.

Conclusion

Seconds and milliseconds are the same measurement at two precisions, and telling them apart is mostly a matter of counting: 10 digits for seconds, 13 for milliseconds, and a forced unit selector for the old values that break the pattern. When a conversion looks absurd, the unit is the first and usually the only suspect. If you have already got a wrong date in front of you, How to Fix Wrong Dates When Converting Unix Timestamps walks the diagnosis in order, and the Developer Tools archive collects the related guides.