What Is a Unix Timestamp (And Why Do Developers Use It)?

A Unix timestamp is a single integer: the number of seconds that have elapsed since January 1, 1970, at 00:00:00 UTC. That moment is called the Unix epoch, and every second since then has been counted without interruption.

The current timestamp right now is somewhere around 1,750,000,000. That number alone tells any computer, database, or API exactly which moment in time you mean — no ambiguity.

Why 1970?

Unix was developed in the late 1960s at Bell Labs. When engineers needed a fixed reference point for time, they picked January 1, 1970 — the start of a new decade, easy to reason about, and conveniently in the recent past so that stored dates wouldn't require negative numbers for anything practical at the time.

It was a pragmatic choice, not a principled one. It stuck.

The Problem Unix Timestamps Solve

Representing dates as human-readable strings creates ambiguity at every layer:

  • Format disagreements: Is 03/04/25 March 4 or April 3? Is it 1925 or 2025?
  • Time zone confusion: "3pm Friday" means a different moment in London vs. Tokyo
  • Locale differences: Some countries write day-month-year, others month-day-year

A Unix timestamp sidesteps all of this. 1711929600 is a single, unambiguous moment in time regardless of where you are or what format you prefer. Machines agree; humans can convert.

Seconds, Milliseconds, and Microseconds

The original Unix timestamp is in seconds. But different systems use different resolutions:

FormatUnitExample
Unix (POSIX)Seconds1711929600
JavaScript Date.now()Milliseconds1711929600000
Python time.time()Seconds (float)1711929600.123
Database timestampsOften microseconds1711929600000000

This is one of the most common sources of bugs when working across systems. A JavaScript timestamp passed directly to a Python or Go function will be 1,000× too large. Always check the resolution when crossing system boundaries.

Reading and Writing Unix Timestamps

In JavaScript / TypeScript

// Current timestamp in seconds
Math.floor(Date.now() / 1000)

// Current timestamp in milliseconds
Date.now()

// Convert timestamp (seconds) to Date object
new Date(timestamp * 1000)

// Convert Date to timestamp (seconds)
Math.floor(new Date('2024-04-01').getTime() / 1000)

In Python

import time, datetime

# Current timestamp (float)
time.time()

# Convert to datetime
datetime.datetime.fromtimestamp(1711929600)

# Convert datetime to timestamp
datetime.datetime(2024, 4, 1).timestamp()

In SQL (PostgreSQL)

-- Current timestamp
EXTRACT(EPOCH FROM NOW())::int

-- Convert to timestamp
TO_TIMESTAMP(1711929600)

Time Zones Don't Affect the Timestamp Itself

This is important and often misunderstood.

A Unix timestamp always represents a moment in UTC. When you display it, you convert to a local time zone. When you store it, you store the UTC value. The timestamp itself is time-zone neutral.

This means:

  • Two users in different time zones storing "now" will get the same timestamp
  • When displaying, each user sees it in their local time
  • No offset adjustments needed in the database — only at the presentation layer

The Year 2038 Problem

Unix timestamps stored as a 32-bit signed integer can only count up to 2,147,483,647 seconds — which corresponds to January 19, 2038, at 03:14:07 UTC. After that, a 32-bit counter wraps to a large negative number.

Systems that still store timestamps as 32-bit integers will break on that date. Most modern systems use 64-bit integers, which pushes the overflow date to the year 292 billion — safely irrelevant for practical purposes.

If you're working with embedded systems, legacy databases, or old C code, it's worth checking how timestamps are stored.

When to Use a Unix Timestamp

Use a Unix timestamp when:

  • Storing dates in a database and you want a simple, sortable integer
  • Passing dates between systems or APIs
  • Comparing or sorting events chronologically
  • Computing durations (just subtract two timestamps)
  • Working with caches or expiry logic (expires_at = now + 3600)

Use a formatted date string when:

  • Displaying a date to a user
  • Logging human-readable events
  • Working in spreadsheets or CSV exports

Quick Conversions

WhatSeconds
1 minute60
1 hour3,600
1 day86,400
1 week604,800
30 days2,592,000
1 year (approx.)31,536,000

The Unix Timestamp Converter converts any timestamp to a human-readable date or converts a date to a Unix timestamp instantly.