Unix Timestamp Explained: How Epoch Time Works

May 27, 20266 min read

What Is a Unix Timestamp?

A Unix timestamp counts the number of seconds elapsed since January 1, 1970, 00:00:00 UTC — known as the Unix epoch. Developers call it epoch time, POSIX time, or Unix time.

Unix epoch: 1970-01-01 00:00:00 UTC → Timestamp 0
Current time (example): 1748300000

The format is simple: one integer, always UTC, no time zones, no formatting ambiguity. That simplicity makes timestamps the backbone of modern software.

Seconds vs Milliseconds

Most systems store timestamps in seconds. JavaScript's Date.now() returns milliseconds instead.

FormatExampleUsed By
Seconds1748300000Unix, Linux, databases, APIs
Milliseconds1748300000000JavaScript, Java, Go

Conversion is straightforward:

  • Seconds → Milliseconds: multiply by 1000
  • Milliseconds → Seconds: divide by 1000 (truncate decimals)
// JavaScript: convert seconds to a Date object
const date = new Date(1748300000 * 1000)
console.log(date.toUTCString()) // "Mon, 26 May 2025 20:53:20 GMT"
# Python: current Unix timestamp in seconds
import time
print(int(time.time()))  # e.g., 1748300000

The Year 2038 Problem

Early Unix systems stored timestamps in a signed 32-bit integer, which maxes out at 2,147,483,647.

Max 32-bit timestamp: 2147483647
Date: 2038-01-19 03:14:07 UTC

After that moment, a 32-bit counter rolls over to a negative number, causing bugs similar to the Y2K issue. The fix? Use 64-bit integers, which support timestamps up to year 292 billion — effectively forever.

Most modern systems and languages already use 64-bit storage, but legacy embedded systems and older file formats may still be vulnerable.

Common Use Cases

  • Databases: Store created_at and updated_at as integers for fast sorting and indexing
  • APIs: Pass timestamps in JSON payloads to avoid timezone parsing issues
  • Caching: Use timestamps for cache invalidation and TTL calculations
  • Logging: Record events with precise, sortable timestamps
  • Scheduling: Cron jobs and task schedulers rely on epoch time internally

Converting Timestamps

By Hand

  1. Take the timestamp value (e.g., 1748300000)
  2. Divide by 86400 to get days since epoch
  3. Add those days to January 1, 1970
  4. Account for leap years

In practice, use a programming language or online converter instead.

In Code

// Get current timestamp
Date.now()                    // milliseconds
Math.floor(Date.now() / 1000) // seconds

// Timestamp to human-readable
new Date(1748300000 * 1000).toISOString() // "2025-05-26T20:53:20.000Z"
# Get current timestamp
import time
time.time()          # float, seconds
int(time.time())     # int, seconds

# Timestamp to human-readable
from datetime import datetime
datetime.utcfromtimestamp(1748300000).isoformat()  # "2025-05-26T20:53:20+00:00"

Key Facts to Remember

  • Unix timestamps are always UTC — no time zone offsets
  • They ignore leap seconds — each day is exactly 86400 seconds
  • Negative timestamps represent dates before 1970
  • JavaScript uses milliseconds; most everything else uses seconds
  • The 2038 problem only affects 32-bit signed integers

Try It Yourself

Use our free Timestamp Converter to convert Unix timestamps to human-readable dates and back — right in your browser.