Lesson 1
What Is a Unix Timestamp?
The epoch, why systems store time as integers, and where timestamps appear.
A Unix timestamp (also called Unix time or epoch time) counts how much time has passed since a fixed starting point called the Unix epoch:
1970-01-01 00:00:00 UTC
That instant is defined as 0. Every moment after it gets a positive integer; moments before 1970 get negative values.
Why integers instead of strings?
Storing time as a number has practical advantages:
- Sorting chronological events is trivial (
ORDER BY created_at) - Arithmetic is easy (duration = end − start)
- Timezone-neutral at storage — the integer names one instant on the global timeline; display layers choose UTC or local formatting
Strings like "2024-06-01T12:00:00" are human-friendly but ambiguous unless you also store offset or timezone rules.
Where you see Unix timestamps
Common places:
- Server logs — often seconds since epoch in one field
- JWT
iat/expclaims — usually seconds - JavaScript —
Date.now()returns milliseconds - PostgreSQL —
EXTRACT(EPOCH FROM ...)returns seconds with fractional part - Mobile analytics — mixed; always check docs
Not the same as “local clock reading”
1700000000 does not mean “5 PM in my city” by itself. It names a single instant; your UI converts that instant to local wall time for display.
Key takeaway
Unix timestamps are portable counters of time since 1970-01-01 UTC. Learn the epoch once and logs, tokens, databases, and API fields become much easier to decode.