2026-05-168 min read

Unix Timestamps Explained (Epoch Time)

Convert between Unix seconds, milliseconds, and human-readable dates — essential for logs, APIs, and databases.

A Unix timestamp is a number representing how many seconds have elapsed since January 1, 1970 at 00:00:00 UTC — a moment called the Unix epoch. This starting point was chosen when Unix was being developed in the early 1970s. Because Unix timestamps count from a fixed UTC moment, they are completely timezone-neutral, which makes them the universal standard for storing and comparing dates across systems, APIs, databases, and programming languages.

Seconds vs milliseconds — the most important distinction

This is the number one source of confusion with Unix timestamps:

FormatDigitsExampleUsed by
Seconds101748678400Unix, Linux, most APIs
Milliseconds131748678400000JavaScript Date.now()

Quick rule: 10-digit timestamp = seconds. 13-digit timestamp = milliseconds.

The symptom of mixing them up: dates appearing in January 1970 (you divided by 1000 when you should not have) or dates in the year 56,000 (you multiplied by 1000 when you should not have).

Converting between them is simple: seconds to milliseconds — multiply by 1000; milliseconds to seconds — divide by 1000.

Code examples

JavaScript:
// Timestamp to date
new Date(1748678400 * 1000).toISOString()
// "2026-05-31T00:00:00.000Z"

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

Python:
from datetime import datetime, timezone
datetime.fromtimestamp(1748678400, tz=timezone.utc)
# datetime(2026, 5, 31, 0, 0, tzinfo=timezone.utc)

SQL:
SELECT FROM_UNIXTIME(1748678400);
-- 2026-05-31 00:00:00

Common use cases

  • JWT tokens — the exp (expiry) and iat (issued at) claims are Unix timestamps in seconds
  • Database columns — storing created_at and updated_at as integers avoids timezone storage issues
  • REST APIs — many APIs return timestamps as Unix integers rather than formatted strings
  • Log files — Unix timestamps sort correctly as integers, making log ordering trivial
  • Cache expiry — setting a cache TTL as a Unix timestamp is reliable across timezones

The Year 2038 problem

On 32-bit systems, Unix time is stored as a signed 32-bit integer, which can hold a maximum value of 2,147,483,647 — corresponding to January 19, 2038 at 03:14:07 UTC. After this moment, 32-bit systems overflow and the timestamp wraps around to a negative number representing 1901. Most modern 64-bit systems are not affected and can represent dates billions of years into the future.

Seconds vs milliseconds — how to tell instantly

The quickest way to identify a Unix timestamp format:

  • 10 digits = seconds (e.g. 1700000000 = Nov 14, 2023)
  • 13 digits = milliseconds (e.g. 1700000000000 = same moment)
  • 16 digits = microseconds (used in some databases and logs)

JavaScript's Date.now() returns milliseconds. Python's time.time() returns seconds (as a float). SQL databases usually store seconds. When a timestamp 'doesn't look right', check whether you need to divide or multiply by 1000.

Converting timestamps in common languages

JavaScript:
// Timestamp to date
new Date(1700000000 * 1000).toISOString()  // multiply seconds by 1000
new Date(1700000000000).toISOString()       // milliseconds directly

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

Python:
import datetime, time
# Timestamp to date
datetime.datetime.fromtimestamp(1700000000)  # local time
datetime.datetime.utcfromtimestamp(1700000000)  # UTC

# Current timestamp
int(time.time())  # seconds

SQL (MySQL/PostgreSQL):
-- Timestamp to date
FROM_UNIXTIME(1700000000)        -- MySQL
TO_TIMESTAMP(1700000000)         -- PostgreSQL

-- Current timestamp
UNIX_TIMESTAMP()                 -- MySQL
EXTRACT(EPOCH FROM NOW())        -- PostgreSQL

FAQ

What is the Unix epoch? January 1, 1970, 00:00:00 UTC. All Unix timestamps count seconds from this point. It was chosen when Unix was designed in the late 1960s as a simple, timezone-independent reference point.

Is a Unix timestamp always in seconds? The standard is seconds, but JavaScript's Date.now() returns milliseconds. Always check which format your system or API expects.

How do I get the current Unix timestamp? Use our converter above, or in code: Math.floor(Date.now() / 1000) in JavaScript, or int(time.time()) in Python.

What is the difference between Unix time and UTC? UTC is a timezone standard. Unix time is a count of seconds since the epoch, always expressed relative to UTC. They are related but not interchangeable terms.

Why do some timestamps start with 1 and others with 17? Timestamps starting with 1 are from the early 2000s (e.g. 1000000000 = September 9, 2001). Timestamps starting with 17 are from the mid-2020s. The number grows by roughly 31.5 million per year.

Why do some APIs return timestamps in milliseconds? JavaScript uses milliseconds internally (Date.now() returns ms), so APIs built with Node.js or browser JavaScript often use milliseconds. Python and most Unix systems use seconds. When integrating APIs, always check the docs for the unit — a 10-digit number is seconds, 13-digit is milliseconds.

What happens in 2038? 32-bit signed integers can hold a maximum of 2,147,483,647 — which equals January 19, 2038 in Unix time. Systems using 32-bit timestamps will overflow on that date. Most modern systems use 64-bit timestamps and are not affected.

Try it yourself

Unix Timestamp Converter

Convert epoch seconds or milliseconds to readable dates and back.

Explore more tools in the Tools Directory.
Browse all articles →