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.
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
Related guides
Frequently asked questions
How do I tell if a Unix timestamp is in seconds or milliseconds?
_ms, trust that over any guess.Why does my timestamp show a date in January 1970?
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?
Is a millisecond timestamp the same moment as the seconds one?
Why do some APIs send milliseconds and others send seconds?
timestamp_ms. Some APIs send an ISO 8601 string instead, which spells out the date and skips the unit question.Related tools
JSON Formatter
Validate, format, and minify JSON. Browse it as a tree, run JSONPath queries, compare two documents, or validate against a JSON Schema.
Use toolCron Generator
Visually build standard 5-part cron expressions or translate them into readable schedules.
Use toolText Encoding Converter
Convert text to Base64, binary, hex, URL encoding and HTML entities, and back again.
Use tool