BaseToolbox LogoBaseToolbox
Blog

© 2025 BaseToolbox. All rights reserved.

Privacy PolicyAboutContact Us

Unix Timestamp: Seconds vs Milliseconds Explained

Published on June 25, 2026

If a timestamp converts to a date in 1970 or far in the future, the first thing to check is whether the value is in seconds or milliseconds.

Unix time counts time from January 1, 1970 UTC. The confusion comes from different systems using different units.

10 Digits Usually Means Seconds

A timestamp like this is usually seconds:

1767225600

In JavaScript, convert seconds by multiplying by 1000:

new Date(1767225600 * 1000);

13 Digits Usually Means Milliseconds

A timestamp like this is usually milliseconds:

1767225600000

JavaScript Date.now() returns milliseconds, so it can be passed directly to Date:

new Date(1767225600000);

Common Mistake

Do not multiply a millisecond timestamp again:

// Wrong if value is already milliseconds
new Date(1767225600000 * 1000);

That pushes the date far into the future.

How to Guess the Unit Safely

Digit count is a useful clue, but it is not a contract. Older dates, future schedules, and truncated values can make the length less obvious.

| Clue | Likely unit | Example | | ---------------- | ------------ | -------------------------- | | Around 10 digits | Seconds | 1767225600 | | Around 13 digits | Milliseconds | 1767225600000 | | Around 16 digits | Microseconds | Some databases and logs | | Around 19 digits | Nanoseconds | High-resolution event logs |

If the converted date is near 1970, you probably treated seconds as milliseconds. If the converted date is thousands of years in the future, you probably multiplied milliseconds again or treated microseconds as milliseconds.

API and Database Checks

Always check the field name and documentation. Names like created_at, createdAtMs, expires_in, iat, and exp often imply different units. JWT iat and exp values are commonly seconds, while JavaScript Date.now() is milliseconds.

For production code, normalize timestamps at the boundary. Convert once when data enters your app, then store and pass one consistent unit internally.

This is especially important for expiration checks. A token, cache entry, or scheduled job can appear valid for far too long if seconds and milliseconds are mixed. When debugging, print both the raw value and the converted UTC date so the mistake is visible immediately.

Quick Answer

Unix timestamps are commonly stored as seconds in APIs and databases, while JavaScript often uses milliseconds. A 10-digit value is usually seconds; a 13-digit value is usually milliseconds.

Useful reference:

  • MDN: Date.now()

Ready to try it yourself?

Put what you have learned into practice with our free online tool.

Convert a Timestamp