Seconds or milliseconds? How to tell which unit a Unix timestamp uses

By TechCompare · Updated · How we check

Count the digits to make a first guess: a value with 10 digits is usually in seconds, and one with 13 digits is usually in milliseconds. Then check the date it gives, because the count can mislead outside the years 2001 to 2286.

One moment, June 3, 2026 at 18:30:00 UTC, is 1780511400 in seconds and 1780511400000 in milliseconds. The seconds value has 10 digits and the milliseconds value has 13. Read one unit as the other and the date is off by a factor of 1000.

Unix timestamp
1,780,511,400
Seconds since epoch
ISO 8601
2026-06-03T18:30:00.000Z
Wed, 03 Jun 2026 18:30:00 GMT
Category
Fundamentals
Timestamp knowledge base

How this is calculated

Seconds and milliseconds count the same moments on different scales, so the digit count follows the unit. From 2001 to 2286, every seconds value has 10 digits and every milliseconds value has 13. Current values all fall in that span, so a number with any other length is either a finer unit, like microseconds, or a bug. The count has one blind spot. Millisecond values for dates from January 12, 1970 to April 26, 1970 also have 10 digits, so a number with 10 digits can be either unit.

Read a millisecond value as seconds and the date lands in year 58392. Depending on the tool, you'll often get an invalid date. Read a seconds value as milliseconds and it lands in 1970: new Date(1780511400) gives January 21, 1970 at 14:35:11 UTC.

When you type a whole number with at least 12 digits and the unit is set to seconds, the converter switches to milliseconds and tells you so. A seconds value that long would land between the years 5138 and 33658, so the converter assumes milliseconds. To read a number with fewer digits as milliseconds, or a long one as seconds, set the unit by hand.

To convert, multiply seconds by 1000 to get milliseconds, and divide milliseconds by 1000 and round down to get seconds. Rounding down matters at the edge. 1780511400999 still counts as second 1780511400, because its last three digits are the fraction of a second. Rounding to the nearest second would give the next one.

Common functions don't agree on the unit, so check each one's docs. JavaScript's `Date.now()` returns milliseconds, and PHP's `time()` returns seconds. Python's `time.time()` returns seconds as a floating-point number, so it can carry a fraction. Go's `Unix()` returns seconds, `UnixMilli()` returns milliseconds, and `UnixNano()` returns nanoseconds. Google Sheets' `EPOCHTODATE` takes seconds, milliseconds or microseconds, and its unit argument says which: 1 for seconds (the default), 2 for milliseconds and 3 for microseconds.

Verdict

Give each field one unit and put it in the name, like created_at_ms, because a bare number doesn't say its unit. Seconds are enough unless two events can land in the same second, and then store milliseconds. Avoid columns that mix both units, and never pass a number to a date function until you know which unit it uses.

More Timestamp scenarios

Frequently asked questions

How do I tell if a Unix timestamp is in seconds or milliseconds?
Read the number both ways and keep the reading that gives a date you expect. A current seconds value read as milliseconds lands in early 1970, and a current milliseconds value read as seconds lands in the year 58392. If the source documents its unit, like a function's docs or a field name ending in _ms, trust that over any guess.
Why does my timestamp show a date in January 1970?
Usually your code read a seconds value as milliseconds. Multiply by 1000 before you pass the value to a function that expects milliseconds, like new Date(seconds * 1000) in JavaScript. A missing value stored as 0 also shows January 1, 1970.
Should I store seconds or milliseconds in a database?
If your database has a native date and time type, use that and skip the integer entirely. For an integer column, seconds are enough for most records. Use milliseconds when two events can land in the same second, such as a busy event log, and put the unit in the column name either way.
Is a millisecond timestamp the same moment as the seconds one?
Yes. The seconds form, 1780511400, and the milliseconds form, 1780511400000, name one moment. Milliseconds are 1000 times finer, and the last three digits hold the fraction of a second, so a whole second ends in three zeros.
Why do some APIs send milliseconds and others send seconds?
Each API picks its own unit, and the number alone doesn't always show which one. Check the docs, or look for a field name that carries the unit, like timestamp_ms. Some APIs send an ISO 8601 string instead, which spells out the date and skips the unit question.