What Is Unix Time? Epoch Seconds Explained (With Examples)
Unix time is a single number that names a moment the same way everywhere on Earth. Here is what that number means, how to read it, and the mistakes that make it off by hours or by a factor of a thousand.
On this page
What Unix time is
Unix time, also called epoch time or POSIX time, is the number of seconds that have passed since 00:00:00 UTC on Thursday, 1 January 1970. That starting instant is the epoch. A timestamp of 0 is the epoch itself, 60 is one minute later, and 1,700,000,000 is 22:13:20 UTC on 14 November 2023. Every moment after the epoch is a positive number, and every moment before it is negative: -1 is 23:59:59 UTC on 31 December 1969.
The idea came from early Unix systems, which needed a compact way to store file dates. A single integer is easy to store, easy to compare and easy to subtract. If one file has a timestamp of 1,798,761,600 and another has 1,798,765,200, you know without any calendar arithmetic that they were saved exactly 3,600 seconds, or one hour, apart. Months of different lengths, leap years and daylight saving do not enter into it.
That simplicity is why the same convention now sits underneath databases, log files, APIs, JSON Web Tokens, cron schedulers and file systems. If you want to translate a value you have found in a log or an API response, paste it into the Unix timestamp converter, or read on to do it by hand.
Seconds versus milliseconds
The original Unix timestamp counts whole seconds. Many modern tools count milliseconds instead, which is the same idea multiplied by 1,000. JavaScript is the most common source of confusion: Date.now() and new Date().getTime() return milliseconds, while Python's time.time(), PostgreSQL's epoch extraction and the Unix date +%s command return seconds. Some systems go further and use microseconds or nanoseconds.
You can usually tell the unit from the length. In 2026 a timestamp in seconds has ten digits, such as 1795132800, which is midnight UTC on 20 November 2026. A timestamp in milliseconds has thirteen digits, such as 1795132800000. Ten-digit values stay ten digits until 20 November 2286, so the digit count is a reliable shortcut for any date you are likely to meet.
Mixing the units produces the classic thousand-fold error. Feed a seconds value into a function that expects milliseconds and January 1970 comes back, because 1,795,132,800 milliseconds is only about 21 days after the epoch. Feed milliseconds into a function that expects seconds and you get a date tens of thousands of years in the future, or an error. If a date looks like 1970 or like the year 58,000, check the unit first.
Why there is no time zone in the number
A Unix timestamp is anchored to UTC, and it carries no time zone at all. The number identifies one instant, and every observer on Earth agrees on it. Time zones only matter when you turn that instant into a clock reading for a person. The timestamp 1798761600 is the same moment in every country, and it reads as follows depending on where you are standing.
| Place | Local reading of 1798761600 | Offset |
|---|---|---|
| UTC | 1 January 2027, 00:00 | UTC+0 |
| New York | 31 December 2026, 19:00 | UTC-5 |
| Berlin | 1 January 2027, 01:00 | UTC+1 |
| Kolkata | 1 January 2027, 05:30 | UTC+5:30 |
| Tokyo | 1 January 2027, 09:00 | UTC+9 |
This is why storing timestamps, rather than local clock text, is the safest way to record when something happened. A timestamp does not change when a country shifts its clocks for daylight saving, which you can see on the daylight saving calendar for 2026. For the difference between UTC and GMT and how offsets work, see the time zone education guide.
Leap seconds and the 86,400-second day
Unix time defines every day as exactly 86,400 seconds. Real UTC occasionally adds a leap second to keep the clock aligned with the Earth's slightly irregular rotation. Twenty-seven leap seconds were added between 1972 and the most recent one, at the end of 2016, and none have been added since. Unix time simply pretends they did not happen. When a leap second is inserted, the timestamp either repeats a value or is smoothed, depending on the operating system, and the two clocks agree again afterwards.
The practical consequence is small. Unix time is not a perfect count of elapsed physical seconds, so subtracting two timestamps across a leap second can be off by one second. For scheduling meetings, billing or logging it never matters, and once a timestamp is converted into a person’s clock time, the main time zone converter handles the rest. In 2022 the international standards community voted to stop adding leap seconds by 2035, which will make the difference even less relevant.
Sample timestamps and their UTC dates
Every value below was converted to UTC, and the last row is the first instant of next year.
| Timestamp (seconds) | UTC date and time | Why it matters |
|---|---|---|
| 0 | 1970-01-01 00:00:00 | The epoch |
| 1000000000 | 2001-09-09 01:46:40 | The billionth second |
| 1700000000 | 2023-11-14 22:13:20 | A popular round number |
| 1798761600 | 2027-01-01 00:00:00 | Start of 2027 |
| 2000000000 | 2033-05-18 03:33:20 | The two-billionth second |
| 2147483647 | 2038-01-19 03:14:07 | Largest signed 32-bit value |
Notice that the figures are spaced by roughly 31.6 million seconds per year. A quick estimate for any date is therefore about 1,970 + (timestamp divided by 31,557,600), which lands within a few weeks of the right year.
The Year 2038 problem
Older systems stored Unix time in a signed 32-bit integer, whose largest value is 2,147,483,647. That number is reached at 03:14:07 UTC on 19 January 2038. One second later the counter overflows and wraps to its most negative value, -2,147,483,648, which software would read as 20:45:52 UTC on 13 December 1901. Programs that rely on the value for expiry dates, certificates, scheduling or file times can crash or behave as though it were the early twentieth century.
Most current systems are safe, because 64-bit time values last for hundreds of billions of years. The risk sits in older embedded devices, legacy databases, file formats and code that deliberately stores timestamps in 32 bits. MySQL's TIMESTAMP column type is a well-known example, as its documented range ends on 19 January 2038; the DATETIME type reaches the year 9999. If you design a new schema today, use a 64-bit integer or a native date-time type. An unsigned 32-bit value would postpone the limit to 7 February 2106, but that only delays the problem.
How to get and convert Unix time in code
Each environment has a short idiom for the current time in seconds and for turning a timestamp into a readable UTC date. The important detail in every row is that the output is explicitly UTC, which avoids the local-time bugs described in the next section.
| Tool | Current time (seconds) | Timestamp to UTC date |
|---|---|---|
| JavaScript | Math.floor(Date.now() / 1000) | new Date(ts * 1000).toISOString() |
| Python | int(time.time()) | datetime.fromtimestamp(ts, timezone.utc) |
| PostgreSQL | extract(epoch from now()) | to_timestamp(ts) at time zone 'UTC' |
| MySQL | UNIX_TIMESTAMP() | CONVERT_TZ(FROM_UNIXTIME(ts), @@session.time_zone, '+00:00') |
| Excel | =(NOW()-DATE(1970,1,1))*86400 (local clock, see note) | =A1/86400+DATE(1970,1,1), formatted as date and time |
The Excel formula for a date in cell A1 is =(A1-DATE(1970,1,1))*86400. It assumes the cell already holds a UTC value, because Excel has no time zone awareness; a spreadsheet that contains local times needs the offset subtracted first. In JavaScript, Date.now() already returns an absolute count, so dividing by 1,000 is all that is needed, and the multiplication by 1,000 in the other direction is the step people forget.
When you only need a one-off answer, a converter is faster and avoids typing mistakes, for example when you are checking a token expiry or a log entry. The Unix timestamp converter shows the result in UTC and in your local zone side by side.
Common bugs and how to avoid them
Reading a UTC value as local time
A server writes 1798761600 and a developer in New York formats it with a local-time function. The page shows 7:00 PM on 31 December 2026, and the report appears to be a day early. Nothing is wrong with the timestamp; the formatting step picked a zone the writer did not intend. Decide whether each displayed value should be UTC, the viewer's zone or a business zone, and state the zone next to it. The same discipline helps with deadlines, as our guide to deadlines across time zones explains.
Off by a factor of 1,000
This is the milliseconds problem from earlier. The defence is a naming convention, such as created_at_s or created_at_ms, and a sanity check that rejects any value that does not fall within a plausible range.
Time-zone-naive date-times
In Python, a datetime without a tzinfo is called naive. Calling .timestamp() on a naive value assumes it is in the machine's local zone, so datetime.utcnow().timestamp() returns a number that is wrong by the machine's UTC offset. Create aware values with datetime.now(timezone.utc) instead. The same trap exists in other languages that silently attach the local zone to a date string.
Converting a local date back to a timestamp across daylight saving
Local time is ambiguous for one hour each autumn and missing for one hour each spring. In the United States in 2026, 1:30 AM on 1 November happens twice and 2:30 AM on 8 March never happens. Convert such times with a library that knows the zone's rules, or store the UTC instant from the start.