VClock

Unix Time Explained: Epoch Timestamps, Milliseconds and the Year 2038 Problem

Behind almost every date on a computer is a single number: the count of seconds since 1 January 1970. This guide explains Unix time, how to convert it, and the pitfalls that catch developers and spreadsheet users.

By the VClock editorial team · Published 21 November 2026 · 5 min read · How we write

Unix time (also called POSIX time or epoch time) is the number of seconds that have elapsed since 00:00:00 UTC on Thursday 1 January 1970, not counting leap seconds. At the moment you load this page it is a ten-digit number around 1.8 billion; the exact time page shows it live. Because it is a single integer that means the same thing everywhere in the world, it is the natural way for computers to store and compare moments in time.

Why 1970?

The Unix operating system was developed at Bell Labs at the end of the 1960s and early 1970s. Early versions counted time in sixtieths of a second from a recent date, which would have overflowed quickly. The developers settled on whole seconds counted from the start of 1970, a round date close to when the system was being written. The choice had no deeper significance, but it spread with Unix, the C programming language and later the POSIX standards, and today the "epoch" of 1970-01-01T00:00:00Z is used far beyond Unix systems.

One number, every time zone

A Unix timestamp identifies an instant, not a local clock reading. The timestamp 1,800,000,000 is 08:00 UTC on 15 January 2027 everywhere: it is 10:00 on that date in Riga, 03:00 in New York and 17:00 in Tokyo. Time zones only enter when you convert the number into a human-readable date. That is why databases and APIs often store timestamps in Unix time or in UTC, and convert to a local zone only for display. For the human-readable equivalent, see our guide to ISO 8601.

Notable timestamps

Unix timeDate and time (UTC)Note
01970-01-01 00:00:00The epoch
1,000,000,0002001-09-09 01:46:40The "billennium", celebrated by programmers
1,234,567,8902009-02-13 23:31:30Another widely noticed milestone
2,000,000,0002033-05-18 03:33:20Next round billion
2,147,483,6472038-01-19 03:14:07Largest value in a signed 32-bit integer

Negative values represent dates before 1970; −86,400 is 31 December 1969 at 00:00 UTC.

Seconds or milliseconds?

The classic Unix timestamp is in seconds, but many systems use milliseconds: JavaScript's Date.now(), Java's System.currentTimeMillis() and many web APIs, for example. Some use microseconds or nanoseconds. A quick way to tell them apart for current dates:

  • 10 digits: seconds (e.g. 1795239866)
  • 13 digits: milliseconds (e.g. 1795239866000)
  • 16 digits: microseconds; 19 digits: nanoseconds

Mixing them up is a common bug. A seconds value interpreted as milliseconds lands in January 1970; a milliseconds value interpreted as seconds lands tens of thousands of years in the future.

How to convert

Command line

date +%s                      # current Unix time (Linux, macOS)
date -u -d @1800000000        # GNU/Linux: timestamp to date
date -u -r 1800000000         # macOS/BSD: timestamp to date

JavaScript

Math.floor(Date.now() / 1000)             // current Unix time in seconds
new Date(1800000000 * 1000).toISOString() // "2027-01-15T08:00:00.000Z"

Python

import time, datetime
int(time.time())
datetime.datetime.fromtimestamp(1800000000, datetime.timezone.utc)

Spreadsheets

Excel, Google Sheets and LibreOffice store dates as a number of days since their own epoch, so you convert by dividing by 86,400 (the seconds in a day) and adding the spreadsheet date for 1 January 1970:

=A1/86400 + DATE(1970,1,1)

Format the cell as a date and time. The result is in UTC; add or subtract your offset as a fraction of a day (for example +2/24 for UTC+2) if you want local time.

Unix time and leap seconds

Unix time pretends every day has exactly 86,400 seconds. When a leap second is added to UTC, Unix time does not count it: in practice the same timestamp is repeated, or the system clock is adjusted or smeared over a period. This keeps conversion simple (every day is 86,400 timestamps long) but means that the difference between two Unix timestamps is not always the exact number of SI seconds that elapsed. For everyday uses this is irrelevant. For scientific measurements or systems that need exact elapsed time across a leap second, other time scales such as TAI are used. Our article on leap seconds explains why they are being phased out.

The year 2038 problem

Many older systems store Unix time in a signed 32-bit integer, which can hold values up to 2,147,483,647. One second after 03:14:07 UTC on 19 January 2038, such a counter overflows and wraps to a large negative number, which would be interpreted as a date in December 1901. This is often compared to the "Y2K" problem.

Modern 64-bit operating systems and most current programming languages use 64-bit time values, which will not overflow for billions of years. The remaining risks are in embedded devices, old file formats, databases with 32-bit timestamp columns and legacy software that will still be running in 2038. Projects such as the Linux kernel and the GNU C library have done substantial work to support 64-bit time even on 32-bit hardware. Organisations with long-lived equipment, such as industrial controllers or vehicles, are the ones that most need to check.

A related date is 2036, when the 32-bit seconds field used in NTP timestamps (counted from 1900) rolls over. The protocol defines "eras" to handle this, but very old implementations may need attention; see how internet time sync works.

Common pitfalls

  • Assuming a timestamp is local time. It never is. Convert it, then apply the zone.
  • Losing precision in floating-point numbers. Very large millisecond or nanosecond values can exceed the precision of some numeric types in spreadsheets and JSON parsers.
  • Calculating days by dividing by 86,400 across a DST change. In local time, the day of a daylight-saving change is 23 or 25 hours long. Use a date library rather than doing arithmetic on timestamps when you mean calendar days.
  • Using the device clock for security decisions. If a device clock is wrong, timestamps it creates are wrong too. Servers should use their own synchronised clocks.

Summary

Unix time is a simple, universal count of seconds since 1970-01-01T00:00:00Z. Convert it to a local time only for display, be clear whether you are using seconds or milliseconds, and remember that 32-bit storage runs out in January 2038.

Related on VClock

Page last reviewed 21 November 2026 by the VClock team. Spotted an error? Tell us.