What Is a Unix Timestamp? Epoch Seconds Since 1970 Explained Simply
Unix timestamps are the numeric way of representing time used everywhere in development: logs, databases, and API responses. This guide explains, for beginners, what a Unix timestamp is, why 1970 is the starting point, how it relates to time zones, millisecond precision, the Year 2038 problem, and how to convert to and from human-readable dates.
You open a log file and see big numbers like "1750000000" used as timestamps, or an API response says created_at: 1719500000. As soon as you work in development, you run into time represented as numbers humans cannot read. That is a Unix timestamp. This article explains what it really is, how it works, the pitfalls people hit, and how to convert it into a readable date.
What Is a Unix Timestamp
A Unix timestamp (also called Unix time, epoch seconds, or POSIX time) represents a moment as the number of seconds elapsed from a fixed reference point. That reference is 00:00:00 UTC on January 1, 1970: that instant is "0," and time is expressed as an integer count of seconds since then.
For example, the value 1719500000 means about 1.7 billion seconds have passed since the 1970 origin, which corresponds to roughly June 27, 2024 in UTC. Unlike a normal date with six parts (year, month, day, hour, minute, second), a Unix timestamp expresses a moment with a single number.
It is widely used for clear reasons:
- Easy to calculate: the gap between two times (elapsed time) is just subtraction, and "one hour later" is simply adding 3600.
- Easy to compare: which is newer is decided by comparing numbers, and sorting is trivial.
- No ambiguity: you never wonder whether it is YYYY/MM/DD or MM-DD-YYYY; the value is the same everywhere in the world.
For these reasons it is used almost everywhere machines handle time: database values, log records, expiry of cookies and tokens, and file modification times.
Why 1970 Is the Starting Point (Epoch)
The reference moment is called the epoch. The Unix timestamp epoch is January 1, 1970 because the scheme was adopted in the UNIX operating system in the early 1970s. A convenient round date in the near future, January 1, 1970, was chosen, and it has since become a global standard.
The key point is that a Unix timestamp is always based on UTC (Coordinated Universal Time). The epoch is not "January 1, 1970 in Tokyo" but "January 1, 1970 in UTC." So no matter where on Earth you count, the same instant yields the same number. This property of being a single, globally shared value is a major advantage for systems that span time zones.
Relationship to Time Zones
The handling of time zones is what confuses beginners most. The bottom line: a Unix timestamp itself contains no time zone information. The value is purely a UTC-based serial number, and a time zone only comes into play when you display it.
For example, the same value 1719500000 shows a different date depending on the display time zone.
| Time zone | Displayed date (example) |
|---|---|
| UTC | 2024-06-27 16:13:20 |
| JST (Japan, UTC+9) | 2024-06-28 01:13:20 |
| EST (US Eastern, UTC-5) | 2024-06-27 11:13:20 |
So while the number (the actual moment) is one thing, how it is shown varies by region. It is easy to forget that the display may be local while the underlying timestamp is UTC-based. Separate the ideas as "timestamp = a UTC serial number" and "time zone = the flavor added at display time," and you will be far less plagued by time-difference bugs.
Seconds, Milliseconds, and Microseconds
A Unix timestamp is fundamentally in seconds, but when finer precision is needed it may be expressed in milliseconds or microseconds. You can usually tell which unit it is by the number of digits.
| Unit | Example | Magnitude |
|---|---|---|
| Seconds | 1719500000 | around 10 digits |
| Milliseconds | 1719500000000 | around 13 digits (x1000) |
| Microseconds | 1719500000000000 | around 16 digits (x1000000) |
Be careful: the default unit differs by language and library. JavaScript's Date.now() returns milliseconds, while PHP's time() and typical usage in Python return seconds. Mixing up seconds and milliseconds gives the classic 1000x-off bug, pointing to "around 1970" or "the far future." Make it a habit to check the digit count: 10 digits means seconds, 13 means milliseconds.
The Year 2038 Problem
A famous topic around Unix timestamps is the Year 2038 problem. It can occur in older systems that store the timestamp as a signed 32-bit integer.
The largest value a signed 32-bit integer can hold is about 2.1 billion, which is reached at 03:14:07 UTC on January 19, 2038. Past that instant the value overflows, wrapping around to a negative number and being mistaken for a past time such as "1901." It is essentially the time-handling version of the Y2K problem.
That said, most modern systems now handle timestamps as 64-bit integers, which can represent times hundreds of billions of years ahead, so there is no practical concern. The risk lies in un-updated legacy embedded devices and old programs. For anything you build new, simply using 64-bit is enough.
Converting To and From Dates
Convenient as Unix timestamps are for machines, humans cannot read them as-is. That is why you need to convert timestamp to date and back. In practice this comes up often:
- When you want to know what moment a number recorded in a log or database refers to.
- When you want to prepare test data or API parameters for a specific date in timestamp form.
- When you want to work out elapsed time (how many days or hours) from the difference between two timestamps.
Doing such conversions on a calculator or by hand is painful. With the Unix Timestamp Converter you simply paste a number to get readable dates in both UTC and your local time, and you can also pick a date to get its timestamp. It supports seconds and milliseconds, so it is handy when you are unsure about the digit count. Everything runs in your browser, so the values you handle are never sent anywhere.
When investigating logs, for instance, you can paste the number in question to pinpoint the moment, then compare it with another number to see "how long the process took" from the difference in seconds. The benefit is getting an instant answer whenever you wonder, "this number, when is it?"
Tips for Handling It in Code
Finally, here are practical points that help when working with Unix timestamps.
- Store in UTC, convert at display time: always store UTC-based timestamps in your database and convert to the local time only when showing it to users. This sharply reduces time-difference bugs.
- Always match the unit (seconds vs milliseconds): when exchanging data between languages, confirm up front whether the other side uses seconds or milliseconds. Checking the digit count is the quick way to tell.
- Use 64-bit for new systems: to avoid the Year 2038 problem, design so that timestamps are handled as 64-bit integers.
- Leap seconds are usually ignored: Unix time is designed not to count leap seconds for convenience, so avoid logic that depends on that rare extra second.
- Make values human-readable when debugging: rather than staring at raw log numbers, convert them to dates with a tool first, and you will reach the cause far faster.
A Unix timestamp is the simple idea of "seconds since 1970," but mixing up time zones or units can produce surprising time-difference bugs. Remember three things: the basis is UTC, check the unit by digit count, and store in UTC while converting at display time. Then you can handle time-related logic with confidence. When a number catches your eye, start by pasting it into the Unix Timestamp Converter to see exactly when it is.
FAQ
What is a Unix timestamp?
It is a way of representing time as the number of seconds elapsed since the epoch, 00:00:00 UTC on January 1, 1970. Also called epoch seconds or POSIX time, it expresses a moment with a single number, making calculation and comparison easy, which is why it is used widely in logs, databases, and APIs.
Why is 1970 the starting point?
The scheme was adopted in the UNIX operating system in the early 1970s, and a convenient round date in the near future, January 1, 1970, was chosen. It became a global standard and is still used today. The reference is always UTC.
Does a Unix timestamp include a time zone?
No. The value is purely a UTC-based serial number, and a time zone only matters at display time. The same value shows a 9-hour difference between UTC and JST (Japan, UTC+9). The rule of thumb is to store in UTC and convert to a local time zone when displaying.
How do I tell seconds from milliseconds?
By the digit count: around 10 digits means seconds, around 13 means milliseconds, and around 16 means microseconds. Defaults differ by language, for example JavaScript Date.now() returns milliseconds while PHP time() returns seconds, so mixing them up causes a 1000x-off bug.
What is the Year 2038 problem?
In older systems that store timestamps as signed 32-bit integers, the value overflows on January 19, 2038 and can be mistaken for the wrong time. Most modern systems use 64-bit, so there is no concern, and new systems avoid it simply by using 64-bit integers.