Skip to main content
Developer Tools August 3, 2026 · 5 min read

What Is a Unix Timestamp and How to Convert It

You've seen numbers like 1716239022 in API responses, JWT tokens, and database columns. These are Unix timestamps — the most common way computers represent a moment in time as a single integer. Understanding them makes debugging time-related bugs much easier.

What Is a Unix Timestamp?

A Unix timestamp (also called "epoch time" or "POSIX time") is the number of seconds elapsed since January 1, 1970, 00:00:00 UTC — a moment known as the Unix epoch.

1716239022

= May 20, 2024, 21:03:42 UTC

Timestamps are timezone-agnostic — a given number represents the same moment in time everywhere on Earth. Time zones are applied only when converting to human-readable form for display.

Seconds vs Milliseconds

This is the most common source of confusion:

Seconds (10 digits)

1716239022

Used by: Unix/Linux, Python, databases, most APIs, JWT exp/iat claims

Milliseconds (13 digits)

1716239022000

Used by: JavaScript's Date.now(), Java, .NET, MongoDB, many frontend frameworks

Quick rule: if the timestamp is 10 digits — seconds. 13 digits — milliseconds. You can also check: the year 2001 is 1000000000 seconds; in milliseconds that's 10^12.

Converting Timestamps in Code

JavaScript

// Get current timestamp
const seconds = Math.floor(Date.now() / 1000);   // seconds
const ms       = Date.now();                       // milliseconds

// Timestamp → Date
const ts = 1716239022;
const d  = new Date(ts * 1000);       // must multiply by 1000!
console.log(d.toISOString());         // "2024-05-20T21:03:42.000Z"
console.log(d.toLocaleDateString());  // depends on locale

// Date → Timestamp
const d2 = new Date('2024-05-20T21:03:42Z');
const ts2 = Math.floor(d2.getTime() / 1000);

Python

import datetime, time

# Get current timestamp
ts = int(time.time())  # seconds since epoch

# Timestamp → datetime (UTC)
dt = datetime.datetime.fromtimestamp(1716239022, tz=datetime.timezone.utc)
print(dt.isoformat())  # 2024-05-20T21:03:42+00:00

# datetime → timestamp
dt = datetime.datetime(2024, 5, 20, 21, 3, 42, tzinfo=datetime.timezone.utc)
ts = int(dt.timestamp())

SQL

-- PostgreSQL
SELECT to_timestamp(1716239022);          -- → '2024-05-20 21:03:42+00'
SELECT EXTRACT(EPOCH FROM NOW())::bigint; -- → current timestamp

-- MySQL
SELECT FROM_UNIXTIME(1716239022);         -- → '2024-05-20 21:03:42'
SELECT UNIX_TIMESTAMP(NOW());             -- → current timestamp

The Year 2038 Problem

On January 19, 2038, 32-bit signed integers used to store Unix timestamps will overflow — rolling back to December 13, 1901. This is the Unix equivalent of Y2K. Modern 64-bit systems can store timestamps reliably until the year 292 billion CE. If you're using 32-bit systems or old databases, migration to 64-bit timestamps should be on your roadmap.

Convert Unix timestamps instantly — free

Timestamp Converter