Unix Timestamp: Seconds vs Milliseconds Explained
Short answer: for Unix timestamp seconds vs milliseconds, remember that a Unix timestamp counts the time since 00:00:00 UTC on 1 January 1970. Count the digits to tell the unit: up to 11 digits is seconds, 12 to 14 is milliseconds, 15 to 17 is microseconds and longer is nanoseconds. If a date shows up in January 1970, a value in seconds was read as milliseconds. The Unix Timestamp Converter detects the unit for you and shows what it decided.
What a Unix timestamp is
It is one number that means the same instant everywhere. Programs, databases and APIs love it because it does not depend on a time zone. The zone only appears when you turn the number into a readable date (see time zones and daylight saving).
1516239022 is 2018-01-18T01:30:22Z. A day later it is exactly 86,400 higher: Unix time ignores leap seconds, so every day has 86,400 seconds.
Telling the unit apart
| Digits | Unit | Typical source | Example | Date (UTC) |
|---|---|---|---|---|
| up to 11 | seconds | Unix date +%s, JWT claims, most databases |
1516239022 |
2018-01-18T01:30:22Z |
| 12 to 14 | milliseconds | JavaScript Date.now(), Java |
1700000000000 |
2023-11-14T22:13:20Z |
| 15 to 17 | microseconds | Some logs and databases | 1700000000000000 |
2023-11-14T22:13:20Z |
| 18 and more | nanoseconds | Go, tracing systems | 1700000000000000000 |
2023-11-14T22:13:20Z |
This rule is a heuristic based on today's dates, not a law. A very small millisecond value or a date far in the past can fool it, which is why the converter prints a "Detected as" line. When a result looks strange, read that line first. Time-ordered IDs such as UUID v7 and ULID embed a millisecond timestamp as well.
The two classic mistakes
Seconds read as milliseconds. 1516239022 as milliseconds is only about 17 days after the epoch, so you get a date in January 1970. If you see 1970 in a UI, this is almost always the reason.
Milliseconds read as seconds. The opposite error gives a date tens of thousands of years in the future. This is also how a JWT can end up "valid forever" when a service writes milliseconds into exp, a claim that is supposed to be seconds. The JWT guide covers that case.
Negative values and the year 2038
Negative timestamps are valid and point before 1970: -86400 is 1969-12-31T00:00:00Z.
A signed 32-bit integer tops out at 2,147,483,647 seconds, which is 2038-01-19T03:14:07Z. Systems that still store time in 32 bits overflow after that moment. Values kept in 64 bits, and the millisecond numbers JavaScript uses, are not affected.
Getting the current timestamp
Pick the language and mind the unit:
| Language | Seconds |
|---|---|
| JavaScript | Math.floor(Date.now() / 1000) (Date.now() alone is milliseconds) |
| Python | int(time.time()) |
| PHP | time() |
| Java | Instant.now().getEpochSecond() |
| Go | time.Now().Unix() |
| C# | DateTimeOffset.UtcNow.ToUnixTimeSeconds() |
| Ruby | Time.now.to_i |
| Bash | date +%s |
| PostgreSQL | EXTRACT(EPOCH FROM now()) |
| MySQL | UNIX_TIMESTAMP() |
Writing dates back: always include the offset
When you type a date without a zone, the result depends on a setting. Add a zone to remove the doubt. 2018-01-18T06:30:22+05:00 is 1516239022 seconds, because +05:00 is five hours ahead of UTC. The format is ISO 8601, and RFC 3339 profiles it for the internet. If a person in Karachi and a person in London are discussing "15:00", the Time Zone Converter shows the same moment in both places, with daylight saving applied.
How to check Unix timestamp seconds vs milliseconds with the converter
- Open the Unix Timestamp Converter.
- Paste a timestamp. The unit is detected from the digit count. Check the Detected as line.
- Read the date in UTC and in your local time.
- To go the other way, type a date such as
2018-01-18,2018-01-18 01:30:22or full ISO 8601 with a zone, and read the seconds and milliseconds. - Choose whether a date without a zone is read as UTC or as your local time.
Limits to know
- The unit is guessed from the digit count. Unusual values can be misread, so confirm with a date you know.
- Unix time has no leap seconds and no time zone. It cannot represent a "local time" by itself.
- Nothing is uploaded. The conversion runs in your browser.
Frequently asked questions
How do I convert a Unix timestamp to a date? Paste it into the Unix Timestamp Converter. It detects seconds or milliseconds and shows UTC and local time.
Why does my timestamp show 1970? A value in seconds was treated as milliseconds. Multiply by 1000 or fix the code that reads it.
Does a Unix timestamp have a time zone? No. It is a count since the epoch in UTC. A time zone matters only when you display it.
What is the year 2038 problem? 32-bit signed time overflows on 19 January 2038 at 03:14:07 UTC.
Is Date.now() in seconds?
No. It returns milliseconds.
Related tools and guides
- Time Zone Converter
- JWT Decoder:
exp,iatandnbfare Unix seconds (see JWT Decoder Guide) - Cron Expression Explainer (see Cron Expression Explained)
- UUID Generator: UUID v7 and ULID carry a timestamp (see UUID v4 vs v7 vs ULID)