What is Unix Time?
Unix time (also known as epoch time, POSIX time, or Unix timestamp) is a way to represent a specific moment in time as a single number — the count of seconds elapsed since 00:00:00 UTC on Thursday, 1 January 1970. That starting point is called the Unix epoch.
Why January 1, 1970?
When the Unix operating system was developed at Bell Labs in the late 1960s and early 1970s, its designers needed a simple, consistent reference point for measuring time. January 1, 1970 was chosen because it was recent, round, and convenient for the systems being built at the time. It has since become the universal standard for time representation in computing.
How Unix Time Works
Every second that passes, the Unix timestamp increments by 1. For example:
0→ 1970-01-01 00:00:00 UTC (the epoch)86400→ 1970-01-02 00:00:00 UTC (one day later)1700000000→ 2023-11-14 22:13:20 UTC
Negative timestamps represent moments before the epoch (before 1970). Most modern systems store timestamps as 64-bit integers, which can represent dates hundreds of billions of years into the future.
Seconds vs. Milliseconds
The Unix standard counts seconds. However, many programming environments
(JavaScript's Date.now(), Java, etc.) return timestamps in
milliseconds — 1000× larger. A 10-digit number is seconds; a 13-digit
number is almost always milliseconds.
Unix Time Does Not Count Leap Seconds
Leap seconds are periodically added to UTC to keep it aligned with Earth's rotation. Unix time intentionally ignores them — every day is treated as exactly 86,400 seconds. This makes arithmetic simple but means Unix time can diverge from civil time by a few seconds.
The Year 2038 Problem
Older 32-bit systems store Unix timestamps as a signed 32-bit integer, which can only
hold values up to 2,147,483,647 — corresponding to
2038-01-19 03:14:07 UTC. After that second, these systems will overflow
and roll back to a negative number (1901). Modern 64-bit systems are not affected and
can safely represent dates until the year 292 billion.
Common Uses in Programming
- Storing created_at / updated_at fields in databases
- Signing and expiring JWT tokens (
iat,expclaims) - HTTP headers like
Last-ModifiedandExpires - Log file timestamps for easy sorting and comparison
- Calculating durations — just subtract two epoch values
- Distributed systems and event ordering
Getting the Current Epoch Time
Here's how to get the current Unix timestamp in common languages:
- JavaScript:
Math.floor(Date.now() / 1000) - Python:
import time; int(time.time()) - Bash / Shell:
date +%s - SQL (PostgreSQL):
EXTRACT(EPOCH FROM NOW()) - Java:
System.currentTimeMillis() / 1000L - Go:
time.Now().Unix() - PHP:
time()