What Is a Unix Timestamp? Epoch Time Explained for Developers
You've seen it in API responses, server logs, database columns, and JWT tokens: a number like 1720915200. It looks meaningless. But that single integer encodes a precise, unambiguous moment in time that any computer on the planet can interpret identically — regardless of timezone, locale, or calendar system. That's the power of a Unix timestamp.
The Problem That Unix Time Was Built to Solve
Before standardized time representations, distributed systems had a serious problem. "Store the event time" sounds simple until your database server is in New York, your application server is in London, and your users are in Mumbai. Which timezone does "2025-07-14 10:30:00" belong to?
Human-readable date strings are inherently ambiguous without explicit timezone context. And even with timezone data attached, parsing, comparing, and sorting date strings across programming languages is fragile and error-prone.
Unix timestamps sidestep all of that. A single integer. No timezone embedded. No locale-specific format. Just the number of seconds since a fixed, universally agreed reference point — midnight UTC on 1 January 1970.
The Unix Epoch is 00:00:00 UTC on Thursday, 1 January 1970. Every Unix timestamp is simply the number of seconds (or milliseconds) elapsed since that exact moment.
Why 1 January 1970? The Real Story
The choice of 1970 wasn't deeply philosophical. When Bell Labs engineers were designing Unix in the late 1960s and early 1970s, they needed a reference point. 1970 was recent enough to avoid massive numbers for contemporary timestamps, and early enough to predate most of the systems they expected to interact with.
Originally, Unix timestamps were stored as a 32-bit signed integer — supporting dates from 1901 to 2038. The choice was practical, not prescient. Nobody in 1970 was planning for the 21st century of internet infrastructure.
Today, most systems use 64-bit integers for timestamps. The theoretical maximum of a 64-bit Unix timestamp is hundreds of billions of years in the future — safely beyond any foreseeable engineering concern.
Seconds vs Milliseconds — How to Tell Them Apart
This is one of the most common sources of confusion. There are two mainstream variants of Unix timestamps, and mixing them up produces dates off by exactly a factor of 1000 — typically a date in 1970 instead of the intended modern date.
| Format | Digits (2025) | Example | Used In |
|---|---|---|---|
| Seconds | 10 | 1720915200 | Unix/Linux, Python, databases, HTTP headers |
| Milliseconds | 13 | 1720915200000 | JavaScript Date.now(), browser APIs, Java |
The rule of thumb: if it's 10 digits, it's seconds. If it's 13 digits, it's milliseconds. This tool auto-detects which you've entered. In your own code, always document which unit your timestamp column or variable uses — it will save a future developer significant debugging time.
How to Work With Unix Timestamps in Real Code
Every major language has native support for Unix timestamp conversion. Here are the patterns you'll use most frequently.
// Current timestamp
const nowSeconds = Math.floor(Date.now() / 1000); // e.g. 1720915200
const nowMs = Date.now(); // e.g. 1720915200000
// Epoch to Date
const date = new Date(1720915200 * 1000);
console.log(date.toUTCString()); // "Mon, 14 Jul 2025 00:00:00 GMT"
console.log(date.toISOString()); // "2025-07-14T00:00:00.000Z"
// Date to Epoch
const ts = Math.floor(new Date('2025-07-14T00:00:00Z').getTime() / 1000);
console.log(ts); // 1720915200import time from datetime import datetime, timezone # Current timestamp now_sec = int(time.time()) # 1720915200 now_ms = int(time.time() * 1000) # 1720915200000 # Epoch to Date (UTC) dt = datetime.fromtimestamp(1720915200, tz=timezone.utc) print(dt) # 2025-07-14 00:00:00+00:00 # Date to Epoch ts = int(datetime(2025, 7, 14, 0, 0, 0, tzinfo=timezone.utc).timestamp()) print(ts) # 1720915200
-- Epoch to Date
SELECT FROM_UNIXTIME(1720915200); -- MySQL
SELECT TO_TIMESTAMP(1720915200); -- PostgreSQL
-- Date to Epoch
SELECT UNIX_TIMESTAMP('2025-07-14 00:00:00'); -- MySQL
SELECT EXTRACT(EPOCH FROM TIMESTAMP '2025-07-14 00:00:00 UTC'); -- PostgreSQLReal Developer Scenarios — Where Timestamps Actually Bite
Vikram, Pune — Node.js Backend Developer
Vikram's e-commerce API stores order creation times as Unix timestamps. A support ticket comes in — "the order shows the wrong date." Vikram pastes the timestamp from the database into the converter and immediately sees the issue: the front-end was treating seconds as milliseconds, displaying a 1970 date to the customer.
Sneha, Bengaluru — Data Engineer
Sneha is building a data pipeline that ingests event logs from three different microservices — one in Python (seconds), one in Node.js (milliseconds), one in Go (nanoseconds). She normalizes everything to milliseconds before writing to the data warehouse. The timestamp converter helps her verify each source's format during testing.
Wei, Singapore — Mobile App Developer
Wei's app schedules push notifications using Unix timestamps passed to a Firebase Cloud Function. He needs to verify that the timestamp for "9:00 AM SGT tomorrow" is correct. He uses the Date to Epoch section, enters the date and time in his local timezone, and gets the exact value to pass to the API.
The Timezone Trap — Why UTC Matters So Much
Unix timestamps are always UTC under the hood. Always. When you call new Date(ts * 1000) in JavaScript and display it, the browser applies your local timezone offset automatically. That's convenient for users — but dangerous in backend code where you need timezone-explicit handling.
Here's a real pattern that trips junior developers: they store a timestamp by calling new Date('2025-07-14') in a Node.js server running in UTC and get midnight UTC. The same code runs on a developer's machine set to IST and produces 18:30 UTC on 13 July — the previous day. Same code, different output, depending on environment timezone.
Always construct dates with explicit UTC in server-side code. Use new Date('2025-07-14T00:00:00Z') or Date.UTC(2025, 6, 14) — never rely on implicit local timezone in backend logic.
The Year 2038 Problem — Should You Worry?
The Y2K38 bug is real but increasingly irrelevant. It only affects systems that store Unix timestamps in a signed 32-bit integer. The maximum value of a signed 32-bit integer is 2,147,483,647, which corresponds to 03:14:07 UTC on 19 January 2038.
On that date, systems using 32-bit timestamps will overflow to a large negative number — jumping back to 13 December 1901 in most implementations. This was a genuine concern in the early 2000s when embedded systems with fixed 32-bit storage were widespread.
If you're working with any legacy embedded system, IoT firmware, or database schema that stores timestamps as INT (32-bit), check whether 2038 is in scope for your product's lifecycle. It's closer than it sounds.
Modern 64-bit systems are not affected at all. A 64-bit signed timestamp won't overflow for approximately 292 billion years. If your database column is BIGINT and your application language uses 64-bit integers (which all modern languages do by default), you have nothing to worry about.
ISO 8601 — The Human-Readable Companion to Unix Time
When you need to store or transmit a date in a human-readable format that's also unambiguous, ISO 8601 is the answer. Format: 2025-07-14T00:00:00.000Z. The trailing Z means UTC. You'll see this in REST API responses, JSON payloads, and CSV exports.
ISO 8601 and Unix timestamps serve different purposes. Use Unix timestamps internally for storage, comparison, arithmetic, and expiry calculations. Use ISO 8601 for display, logging, inter-system communication, and anywhere a human might need to read the value directly.
Unix Timestamps Across Languages — Quick Reference
Convert Any Unix Timestamp Instantly
Use the free Unix Timestamp Converter — bidirectional, live epoch display, UTC and local time, ISO 8601, one-click copy. No signup needed.
Open the Unix Timestamp Converter →Recommended Hosting
Hostinger
If you are building a website for your tools, blog, or store, reliable hosting matters for speed and uptime. Hostinger is a popular option used worldwide.
Visit Hostinger →Disclosure: This is a sponsored link.
Contact Us
Have a question or want to suggest a topic? We'd love to hear from you.
