Unix Time Explained: Epoch Seconds, Leap Seconds and 2038
Unix time, also called POSIX time or epoch time, is the number of seconds that have elapsed since 00:00:00 UTC on 1 January 1970, not counting leap seconds. Every day is treated as exactly 86,400 seconds, which makes timestamps easy to store, compare and convert. It is the internal clock of most operating systems, databases and programming languages.
- Type
- Count of seconds
- Epoch
- 1 January 1970, 00:00:00 UTC
- Length of a day
- Exactly 86,400 seconds
- Leap seconds
- Ignored
- Epoch as Julian Day
- JD 2,440,587.5 (MJD 40,587)
- 32-bit signed limit
- 2,147,483,647 = 19 January 2038, 03:14:07 UTC
Definition
The POSIX standard defines seconds since the Epoch with an arithmetic formula: the number of whole days since 1 January 1970 multiplied by 86,400, plus the hours, minutes and seconds of the current UTC day. Because the formula assumes every day has 86,400 seconds, Unix time is not a true count of elapsed SI seconds; it is a uniform encoding of the UTC calendar date and time of day.
Times before 1970 are negative. Many programming environments count in smaller units: JavaScript's Date and Java's System.currentTimeMillis use milliseconds since the same epoch, and some systems use microseconds or nanoseconds. A 13-digit timestamp in the 2020s is almost always milliseconds, while a 10-digit one is seconds.
| Unix time | UTC date and time |
|---|---|
| 0 | 1 January 1970, 00:00:00 |
| 946,684,800 | 1 January 2000, 00:00:00 |
| 1,000,000,000 | 9 September 2001, 01:46:40 |
| 1,700,000,000 | 14 November 2023, 22:13:20 |
| 1,767,225,600 | 1 January 2026, 00:00:00 |
| 2,000,000,000 | 18 May 2033, 03:33:20 |
| 2,147,483,647 | 19 January 2038, 03:14:07 |
| −2,147,483,648 | 13 December 1901, 20:45:52 |
Converting a timestamp by hand
Since every day has 86,400 seconds, the date and the time of day separate cleanly. Divide the timestamp by 86,400: the whole part is the number of days since 1 January 1970, and the remainder is the number of seconds since midnight UTC. Add the day count to 1 January 1970 with any calendar tool, or add 40,587 to get the Modified Julian Day.
For example, 1,000,000,000 ÷ 86,400 gives 11,574 days with a remainder of 6,400 seconds. Day 11,574 after the epoch is 9 September 2001, and 6,400 seconds is 1 hour, 46 minutes and 40 seconds, giving 01:46:40 UTC.
The weekday is also simple: 1 January 1970 was a Thursday, so the weekday repeats every 7 days of 86,400 seconds from there.
| To get | Formula |
|---|---|
| Days since 1970 | floor(Unix ÷ 86,400) |
| Julian Day | Unix ÷ 86,400 + 2,440,587.5 |
| Modified Julian Day | Unix ÷ 86,400 + 40,587 |
| Rata Die | floor(Unix ÷ 86,400) + 719,163 |
What happens to leap seconds
UTC is kept close to the rotation of the Earth by inserting occasional leap seconds. Between 1972 and the end of 2016, 27 leap seconds were added, so UTC is now 37 seconds behind International Atomic Time (TAI). Unix time does not count these seconds. When a leap second is inserted at 23:59:60 UTC, a typical system either repeats the timestamp of the last second of the day or adjusts its clock gradually over a period around the leap second, a technique known as smearing.
The practical consequences are that the difference between two Unix timestamps can be off by the number of leap seconds between them, and that a Unix timestamp alone cannot distinguish 23:59:60 from the following or preceding second. For most applications this is harmless; for scientific timing, systems use TAI, GPS time or another continuous scale.
In 2022 the General Conference on Weights and Measures decided that the tolerance between UTC and UT1 should be increased by or before 2035, which is expected to end the insertion of leap seconds for at least a century.
The year 2038 problem
Older Unix systems stored time in a signed 32-bit integer (time_t). The largest value it can hold is 2,147,483,647, which corresponds to 03:14:07 UTC on Tuesday, 19 January 2038. One second later, the counter overflows to −2,147,483,648, which such software interprets as 20:45:52 UTC on 13 December 1901.
Modern 64-bit operating systems use a 64-bit time_t, which is good for billions of years. The remaining risk lies in embedded devices, old file formats, database columns and network protocols that still store 32-bit timestamps. An unsigned 32-bit field lasts until 06:28:15 UTC on 7 February 2106, but cannot represent dates before 1970.
| Storage | Earliest | Latest |
|---|---|---|
| Signed 32-bit seconds | 13 December 1901, 20:45:52 UTC | 19 January 2038, 03:14:07 UTC |
| Unsigned 32-bit seconds | 1 January 1970, 00:00:00 UTC | 7 February 2106, 06:28:15 UTC |
| Signed 64-bit seconds | About 292 billion years ago | About 292 billion years from now |
Time zones and the converter
A Unix timestamp has no time zone: it identifies the same instant everywhere. Converting it to a local date and time requires a time zone database, because the same timestamp can fall on different calendar dates in Tokyo and in Los Angeles.
This site's converter shows the Unix time at midnight UTC at the start of the selected date. For example, 1 January 2025 is shown as 1,735,689,600. To find the value for a specific time of day, add the number of seconds since midnight UTC.
Common pitfalls
Most bugs involving Unix time come from units, time zones and storage size rather than from the definition itself.
- Mixing seconds and milliseconds, which shifts a date by a factor of 1,000 and usually lands it in January 1970 or tens of thousands of years in the future.
- Treating a local wall-clock time as UTC, which shifts the result by the time zone offset.
- Assuming that every minute has 60 seconds in UTC; around a leap second it can have 61.
- Storing timestamps in 32-bit fields that will overflow in 2038.
Frequently asked questions
What is Unix time?
It is the number of seconds since 00:00:00 UTC on 1 January 1970, with every day counted as exactly 86,400 seconds and leap seconds ignored.
Does Unix time include leap seconds?
No. POSIX defines every day as 86,400 seconds, so leap seconds are not counted and the clock repeats or smears a second when one occurs.
What is the year 2038 problem?
Signed 32-bit timestamps overflow after 2,147,483,647 seconds, at 03:14:07 UTC on 19 January 2038, and wrap to a date in December 1901.
Is a Unix timestamp in seconds or milliseconds?
The POSIX value is in seconds. JavaScript, Java and many web APIs use milliseconds, which gives 13-digit values for current dates.
Can Unix time be negative?
Yes. Negative values represent instants before 1 January 1970 UTC.
Does Unix time depend on the time zone?
No. It is always based on UTC; only its conversion into a local date and time depends on the time zone.
Sources and further reading
- The Open Group Base Specifications (POSIX), Base Definitions, General Concepts: Seconds Since the Epoch
- International Earth Rotation and Reference Systems Service (IERS), Bulletin C (leap second announcements)
- Bureau International des Poids et Mesures, Resolution 4 of the 27th General Conference on Weights and Measures (2022), on the use and future development of UTC