What is a Unix timestamp?
A Unix timestamp (also called epoch time) represents a moment by counting from the Unix epoch: 1970-01-01 00:00:00 UTC. In POSIX, the time() function returns seconds since that reference point.[1] POSIX time ignores leap seconds, so this is a conventional time scale rather than a literal count of every SI second that has elapsed. [2]
The number identifies an instant; it does not include a display time zone. You can render the same instant in UTC or in a local time zone. When you exchange a calendar date and time as text instead, include its UTC relationship—for example, the Z in an RFC 3339 value such as 2023-11-14T22:13:20Z means UTC; RFC 3339 defines this date-time format.[3][4]
For example, 1700000000 seconds and 1700000000000 milliseconds identify the same instant: 2023-11-14 22:13:20 UTC. The units differ by a factor of 1,000; the instant does not.[1][3]
Seconds vs. milliseconds
Traditional POSIX timestamps count seconds. JavaScript Date values use milliseconds since the same epoch, and Date.now() returns milliseconds, as described in MDN's Date documentation.[1][3] That difference is a common source of conversion mistakes: code that expects milliseconds will interpret a seconds value as a much earlier date, while a seconds-based system may misread a millisecond value as an implausibly large future value.[3]
const seconds = 1_700_000_000;
const date = new Date(seconds * 1000); // Date expects milliseconds
const millisecondsNow = Date.now();
const wholeSecondsNow = Math.floor(millisecondsNow / 1000);
A familiar modern value is often 10 digits when measured in seconds and 13 digits in milliseconds, but digit count is only a clue—not a data contract.[1][3] Dates outside the usual range, negative timestamps, and microsecond or nanosecond formats can have different lengths. Check the producing API, field documentation, or database schema before converting.
If you are unsure what a value means, try the Timestamp Converter and compare its result with the expected date. The tool guesses between common seconds and milliseconds magnitudes; treat that guess as a quick check, not proof of the original unit.
Timestamps and time zones
A timestamp refers to an instant, not a location's wall-clock schedule.[3][4] Changing the display time zone changes the calendar reading, not the instant. For example, 2023-11-14T22:13:20Z and the same moment displayed at a local UTC offset refer to one event; RFC 3339 date-time strings include an explicit relationship to UTC.[3][4]
For logs, APIs, or event records, a numeric timestamp can be compact and easy to compare, but document whether the number is seconds or milliseconds.[1][3] For a future appointment such as “09:00 in London,” keep the intended time zone as well as the local date and time: an offset alone may not describe the zone's rules on a different date.[4] See the time-zone guide for the difference between offsets and named zones.
The Year 2038 problem
A signed 32-bit integer can represent at most 2,147,483,647. Interpreted as POSIX seconds, that is 2038-01-19 03:14:07 UTC; one second later is outside that signed range. That is the Year 2038 problem for systems that still store epoch seconds in a signed 32-bit field, as explained in the POSIX.1-2024 rationale.[2]
It is not a deadline at which every computer or timestamp stops working. POSIX.1-2024 requires time_t to be an integer type at least 64 bits wide in conforming programming environments.[5][6] Legacy devices, file formats, database columns, and interfaces can still impose narrower limits, so check every representation in the data path instead of assuming the processor's bitness tells you the timestamp width.[2]
A practical conversion checklist
- Find the unit in the source contract. Prefer API or schema documentation over guessing from the number of digits.
- Check the expected date. A result in 1970 or far in the future can indicate a seconds/milliseconds mix-up, but it can also mean the value is genuinely old, future-dated, or in another precision.[3]
- Convert deliberately. Multiply seconds by 1,000 before passing them to JavaScript
Date; divide milliseconds by 1,000 when a seconds-based interface requires whole seconds.[3] - Choose a display time zone. The timestamp alone does not tell you which local clock reading a person expects.
- Keep the original value and unit. Avoid silently rewriting stored data based on a heuristic.
Frequently asked questions
What does a Unix timestamp measure?
It is a numeric representation counted from 1970-01-01 00:00:00 UTC. POSIX-style timestamps count seconds and do not add leap seconds to the count.[1][2]
Are Unix timestamps in seconds or milliseconds?
The conventional POSIX time() value is in seconds. JavaScript Date values, including Date.now(), use milliseconds; other APIs may choose a different unit, so check their documentation.[1][3]
Can I tell the unit by counting digits?
Digit length can help for common modern seconds and milliseconds values, but it is not reliable for every date or precision. Confirm the field's documented unit, then check that the converted date is plausible.
Does a Unix timestamp contain a time zone?
No. It represents an instant. A time zone is needed to display that instant as local calendar time; a numeric UTC offset or RFC 3339 text can make the relationship explicit.[3][4]
Does Unix time count leap seconds?
POSIX seconds-since-the-Epoch ignore leap seconds. Applications that need leap-second-aware or other specialized time-scale behavior must follow a format and clock source designed for that requirement.[2][3]
What is the Year 2038 problem?
A signed 32-bit seconds counter reaches its maximum at 2038-01-19 03:14:07 UTC. Systems still relying on that narrow representation cannot represent later values correctly; the issue concerns the data type and interfaces, not every computer.[2]
Why does Unix time start in 1970?
1970-01-01 00:00:00 UTC is the defined Unix epoch: the shared reference point for these counts. Treat it as a convention, not as a timestamp unit or a local time zone.[2]
Sources
[1] The Open Group Base Specifications Issue 8 (POSIX.1-2024), time()
[2] The Open Group Base Specifications Issue 8 (POSIX.1-2024), Rationale for Base Definitions
[4] RFC 3339, Date and Time on the Internet: Timestamps
[5] The Open Group Base Specifications Issue 8 (POSIX.1-2024), sys_types.h header