Skip to content

What Is Unix Time? Epoch Timestamps Explained for Developers and the Curious

By Vclock · · 7 min read

If you have ever looked at a database, a log file or an API response and seen a long number such as 1700000000 where you expected a date, you have met Unix time. It looks strange, but it is one of the simplest and most useful ideas in computing: a single number that stands for a moment in time. Once you know how to read it, a lot of technical mysteries disappear.

This guide explains what Unix time is, where it comes from, how to read and convert it, the difference between seconds and milliseconds, how to get the current timestamp in several languages, what the year 2038 problem is and the mistakes that trip up developers most often. You can try any value on our Unix timestamp converter as you read.

The definition

A Unix timestamp is the number of seconds that have passed since 00:00:00 on 1 January 1970, in Coordinated Universal Time, UTC. That starting moment is called the Unix epoch. A timestamp of 0 is the epoch itself, 86400 is exactly one day later, and so on. It is also called epoch time, POSIX time or simply a timestamp.

Because the number counts from one fixed moment in UTC, it has no time zone and no daylight saving time. The timestamp 1700000000 means the same instant in Tokyo, Paris and Los Angeles. Only the way it is written as a date and a clock time changes with the zone.

Where it comes from

The idea comes from the early days of the Unix operating system at Bell Labs. The first versions counted time in sixtieths of a second, following the frequency of the electricity supply, from a starting date of 1971. Stored in a 32-bit number, that count would overflow in about two and a half years, so the designers soon changed it to count whole seconds, and moved the starting date to the round date of 1 January 1970.

Unix and its descendants, such as Linux, macOS, Android and iOS, spread widely, along with languages such as C, Python and JavaScript. As a result, the Unix timestamp became a common language for computers to exchange times.

Why developers like it

  • It is one number, so it is easy to store, compare and sort. A larger number is always a later time.
  • It has no time zone, which means no ambiguity about which hour a time refers to.
  • Arithmetic is simple. One minute is 60, one hour is 3,600 and one day is 86,400 seconds, so you can add or subtract times directly.
  • It takes little space and works in every programming language and database.

Seconds, milliseconds and more

Many systems count whole seconds, which today gives a 10 digit number, for example 1700000000. Others need more precision. JavaScript, Java and many web APIs use milliseconds, which gives a 13 digit number such as 1700000000000. Some systems use microseconds, with 16 digits, or nanoseconds, with 19 digits.

Mixing them up is the most common timestamp bug. A value in milliseconds read as seconds gives a date tens of thousands of years in the future. A value in seconds read as milliseconds gives a date in January 1970, a few weeks after the epoch. If you see 1970, check the units first. Our converter reads the number as seconds or milliseconds automatically, based on its size, and you can also set it yourself.

Some example values

  • 0 is 1970-01-01 00:00:00 UTC, the Unix epoch
  • 86400 is 1970-01-02 00:00:00 UTC
  • 1000000000 is 2001-09-09 01:46:40 UTC
  • 1234567890 is 2009-02-13 23:31:30 UTC
  • 1700000000 is 2023-11-14 22:13:20 UTC
  • 2000000000 is 2033-05-18 03:33:20 UTC
  • 2147483647 is 2038-01-19 03:14:07 UTC, the largest signed 32-bit value

Developers sometimes celebrate when the counter reaches a round number. When the timestamp passed 1,000,000,000, in September 2001, and again at 1,234,567,890, in February 2009, there were small parties around the world.

How to get the current timestamp

  • JavaScript: Math.floor(Date.now() / 1000) for seconds, or Date.now() for milliseconds
  • Python: int(time.time())
  • PHP: time()
  • Java: Instant.now().getEpochSecond()
  • Go: time.Now().Unix()
  • Bash and Linux shells: date +%s
  • SQL: the function name differs by database, for example UNIX_TIMESTAMP() in MySQL

To turn a timestamp back into a date, most languages offer a function that takes the number and, if you wish, a time zone. In JavaScript, for example, you multiply seconds by 1000 and pass the result to the Date constructor.

Negative timestamps

A timestamp is just a number, so it can also be negative. A negative value is a moment before the epoch. The timestamp minus 86400 is 31 December 1969. Not every system handles negative values correctly, so check before you rely on them for old dates, such as birth dates.

The year 2038 problem

Many older systems store the timestamp in a signed 32-bit integer. The largest value such a number can hold is 2,147,483,647, which falls at 03:14:07 UTC on 19 January 2038. One second later, the number overflows and wraps around to a large negative value, which a computer reads as a date in December 1901. This is known as the year 2038 problem, or Y2K38.

Most modern systems already use 64-bit numbers. A signed 64-bit timestamp counted in seconds would not overflow for about 292 billion years, far longer than the age of the universe. The risk remains in old software, embedded devices, file formats and databases that still use 32-bit fields. Some database column types, such as the TIMESTAMP type in MySQL, have a range that ends in 2038 for that reason. If you maintain a system that stores dates far in the future, such as a mortgage or a certificate, check the field type.

Leap seconds

Unix time acts as if every day has exactly 86,400 seconds. It does not count leap seconds, which are added to UTC from time to time. When a leap second occurs, systems typically repeat a second or smooth it across a longer period, so the timestamps stay in step, but the exact method differs. For almost all applications, you can ignore this. For scientific work that needs exact elapsed time, use a time scale that does count them. We explain the background in our guide to how clocks work.

Common mistakes

  • Confusing seconds with milliseconds, which gives dates in 1970 or in the far future.
  • Storing a local time instead of UTC, which breaks when daylight saving time changes or when users travel.
  • Adding 86,400 seconds to get tomorrow at the same local time. On days when clocks change, a local day is 23 or 25 hours long.
  • Showing a timestamp to users without converting it to their own time zone.
  • Using a 32-bit field for a timestamp that may pass 2038.
  • Treating a timestamp as a string and sorting it alphabetically. Sort numbers as numbers.

Unix time and other formats

People find Unix timestamps hard to read, so for display and for text files, another standard is often better. ISO 8601 writes a date and time as text, for example 2026-07-16T09:00:00-04:00, with the time zone offset included. Many systems store timestamps for machines and show ISO 8601 or a local date format to people. If you want to work out how a moment looks in different places, use the time zone converter, or compare the time in other countries on the world clock.

Where you meet timestamps

  • Database fields such as created_at and updated_at.
  • Log files, where each line starts with a time.
  • APIs, which return times as numbers or as ISO 8601 text.
  • JSON Web Tokens, which record when they expire as a Unix time in seconds.
  • File systems, which record when files were created and changed.
  • Cookies and caches, which have an expiry time.

The bottom line

Unix time is a count of seconds since the start of 1970 in UTC. It is simple, free of time zones and easy to calculate with, which is why it is everywhere in software. Remember to check whether you are looking at seconds or milliseconds, store times in UTC and convert them only when you show them to a person, and make sure that any field that must work past January 2038 can hold it. For a quick conversion in either direction, use the Unix timestamp converter.

Frequently asked questions

What is a Unix timestamp?+

A Unix timestamp is the number of seconds that have passed since 00:00:00 UTC on 1 January 1970, a moment called the Unix epoch. It is a simple way for computers to store and compare times.

How do I tell seconds from milliseconds?+

A timestamp in seconds has 10 digits today, like 1700000000. A timestamp in milliseconds has 13 digits, like 1700000000000. If a converted date lands in January 1970, you probably read milliseconds as seconds, or the other way round.

Does a Unix timestamp have a time zone?+

No. It counts from a fixed moment in UTC, so the same number means the same instant everywhere. Only the readable date and clock time change with the time zone.

What is the year 2038 problem?+

Systems that store the timestamp in a signed 32-bit integer overflow at 2,147,483,647, which is 03:14:07 UTC on 19 January 2038. After that, the value wraps to a negative number. Systems that use 64-bit numbers do not have this limit.

How do I get the current Unix timestamp?+

In JavaScript use Math.floor(Date.now() / 1000), in Python use int(time.time()), in PHP use time(), and in a Linux shell use date +%s. The Unix timestamp converter on this site also shows the current value.

Are leap seconds included in Unix time?+

No. Unix time treats every day as exactly 86,400 seconds, so leap seconds are not counted. Systems handle a leap second by repeating a second or smoothing it out.