Toolmingo
Guides4 min read

What Is a Unix Timestamp? Epoch Time Explained

Learn what a Unix timestamp is, why it starts at January 1, 1970, how to convert it to a human-readable date, and how to work with it in JavaScript, Python, Go, and PHP.

When you look at a database row and see a column called created_at with a value like 1720793600, you're looking at a Unix timestamp. It's one of the most common ways computers store time — and it has a few quirks that are worth understanding.

What is a Unix timestamp?

A Unix timestamp (also called epoch time or POSIX time) is the number of seconds that have elapsed since midnight UTC on January 1, 1970 — a date known as the Unix epoch.

1720793600 = Saturday, July 12, 2025, 16:13:20 UTC

It's just a number. No timezone. No locale. No formatting. Just an integer that represents a specific moment in time, the same way for everyone on the planet.

Why January 1, 1970?

When Unix was being developed in the late 1960s and early 1970s, the designers needed a fixed reference point for time. They chose January 1, 1970 because it was recent, convenient, and round. There's no deeper significance to the date — it was a practical decision that has outlasted the original Unix systems by decades.

Seconds, milliseconds, and microseconds

Different systems use different precision:

Unit Example Used in
Seconds 1720793600 Unix/POSIX standard, databases, most APIs
Milliseconds 1720793600000 JavaScript Date.now(), Java
Microseconds 1720793600000000 Python time.time_ns(), some databases
Nanoseconds 1720793600000000000 Go time.Now().UnixNano()

The most common mistake with timestamps is confusing seconds and milliseconds. If you get a date that looks like it's in 2055 when you expected 2025, you probably have milliseconds where the system expects seconds (multiply by 1000 or divide by 1000 accordingly).

A quick way to tell: a 10-digit timestamp is seconds; a 13-digit timestamp is milliseconds.

Getting the current timestamp

JavaScript:

// Seconds
const ts = Math.floor(Date.now() / 1000);

// Milliseconds (JavaScript native)
const tsMs = Date.now();

Python:

import time

# Seconds (float)
ts = time.time()

# Seconds (integer)
ts_int = int(time.time())

# Milliseconds
ts_ms = int(time.time() * 1000)

Go:

import "time"

// Seconds
ts := time.Now().Unix()

// Milliseconds
tsMs := time.Now().UnixMilli()

// Nanoseconds
tsNs := time.Now().UnixNano()

PHP:

// Seconds
$ts = time();

// Milliseconds
$tsMs = (int)(microtime(true) * 1000);

Bash / command line:

# Seconds
date +%s

# Milliseconds (GNU date)
date +%s%3N

Converting a timestamp to a date

JavaScript:

const ts = 1720793600;

// Create a Date object (from seconds)
const date = new Date(ts * 1000);

// Format it
console.log(date.toISOString());       // "2025-07-12T16:13:20.000Z"
console.log(date.toLocaleDateString()); // "7/12/2025" (locale-dependent)

// Get parts
console.log(date.getUTCFullYear());    // 2025
console.log(date.getUTCMonth() + 1);   // 7 (months are 0-indexed)
console.log(date.getUTCDate());        // 12

Python:

from datetime import datetime, timezone

ts = 1720793600

# Convert to UTC datetime
dt = datetime.fromtimestamp(ts, tz=timezone.utc)
print(dt)                    # 2025-07-12 16:13:20+00:00
print(dt.strftime("%Y-%m-%d"))  # 2025-07-12

Go:

import (
    "fmt"
    "time"
)

ts := int64(1720793600)
t := time.Unix(ts, 0).UTC()
fmt.Println(t.Format(time.RFC3339)) // 2025-07-12T16:13:20Z
fmt.Println(t.Format("2006-01-02")) // 2025-07-12

PHP:

$ts = 1720793600;

$date = new DateTime("@{$ts}");
$date->setTimezone(new DateTimeZone('UTC'));
echo $date->format('Y-m-d H:i:s'); // 2025-07-12 16:13:20

Converting a date to a timestamp

JavaScript:

// From a date string (UTC)
const ts = Math.floor(new Date("2025-07-12T16:13:20Z").getTime() / 1000);

// From explicit UTC values
const ts2 = Math.floor(Date.UTC(2025, 6, 12, 16, 13, 20) / 1000);
// Note: months are 0-indexed (6 = July)

Python:

from datetime import datetime, timezone

dt = datetime(2025, 7, 12, 16, 13, 20, tzinfo=timezone.utc)
ts = int(dt.timestamp())
print(ts)  # 1720793600

The year 2038 problem

Unix timestamps stored as a 32-bit signed integer can only represent dates up to January 19, 2038, 03:14:07 UTC. After that, the value overflows to a large negative number.

Most modern systems already use 64-bit integers for timestamps, which won't overflow for about 292 billion years. But embedded systems, legacy databases, and older C libraries may still be at risk. If you're working with systems that store timestamps as 32-bit integers, this is worth checking.

Timestamps and time zones

Unix timestamps are always in UTC. There is no such thing as a "timezone-aware Unix timestamp" — the timestamp itself is absolute. Timezone conversion happens only when you display the time to a user.

This is why timestamps are so useful for storage: you store one number and let each client display it in their local time.

1720793600 UTC = 09:13:20 PDT (Los Angeles, UTC-7)
1720793600 UTC = 18:13:20 CEST (Berlin, UTC+2)
1720793600 UTC = 00:13:20 JST (Tokyo, UTC+9, next day)

Convert timestamps online

If you need to quickly convert between a Unix timestamp and a readable date, use the Unix Timestamp Converter. Paste in a timestamp and get the date, or pick a date and get the timestamp. Runs in your browser with no server calls.

FAQ

Q: Why is my timestamp 13 digits long? You have milliseconds, not seconds. Divide by 1000 to get seconds.

Q: How do I store a timestamp in a database? For PostgreSQL, use TIMESTAMPTZ (timestamp with time zone) — it stores the value as UTC internally and handles conversion. If you're storing as an integer, use BIGINT (64-bit) to avoid the 2038 problem. Avoid INTEGER (32-bit) for timestamps.

Q: Is a Unix timestamp always an integer? Not necessarily. Python's time.time() returns a float with sub-second precision. But most systems that store timestamps in databases or transmit them in JSON use integers (seconds or milliseconds), which are easier to work with consistently.

Q: What does "epoch" mean? In computing, "epoch" refers to the reference point from which time is measured. The Unix epoch is January 1, 1970, 00:00:00 UTC. Other systems have different epochs: Windows FILETIME uses January 1, 1601; Apple's Core Data uses January 1, 2001.

Related tools

Keep reading

All Toolmingotools are free & run in your browser

No sign-up, no upload, no watermark. Your files never leave your device.

Browse all tools