Unix Timestamp to Date: Converter, Format Guide, and Common Pitfalls
Learn what Unix timestamps are, how to convert them to human-readable dates in JavaScript, Python, and SQL, and how to avoid the most common timestamp bugs.
Try the free online tool mentioned in this guide:Timestamp Converter
What is a Unix timestamp?
A Unix timestamp (also called epoch time or POSIX time) is the number of seconds that have elapsed since January 1, 1970 00:00:00 UTC (the Unix epoch). It is a single integer that uniquely identifies any moment in time, making it ideal for storing, transmitting, and comparing datetimes in APIs, databases, and logs.
Because it is timezone-agnostic (always UTC-based), timestamps avoid the ambiguity of local time strings across regions and daylight saving changes.
// Right now (seconds since epoch)
1716240000
// As a human-readable date (UTC)
// 2024-05-21 00:00:00 UTCSeconds vs milliseconds
The biggest source of timestamp bugs is confusing seconds and milliseconds. Unix timestamps are traditionally in seconds. JavaScript's Date.now() and many modern APIs return milliseconds. A timestamp of 1716240000000 (13 digits) is milliseconds; 1716240000 (10 digits) is seconds.
Always check whether an API returns seconds or milliseconds before storing or displaying a timestamp.
// Seconds (10 digits) — Unix standard
1716240000
// Milliseconds (13 digits) — JavaScript Date.now()
1716240000000
// Rule of thumb
if (timestamp > 1e12) {
// milliseconds — divide by 1000 for seconds
}Converting timestamps in JavaScript
JavaScript's Date accepts milliseconds in its constructor. Multiply seconds-based timestamps by 1000 before passing them.
const ts = 1716240000 // seconds
// To Date object
const date = new Date(ts * 1000)
// To ISO string (UTC)
date.toISOString() // "2024-05-21T00:00:00.000Z"
// To locale string (local timezone)
date.toLocaleString() // "5/21/2024, 8:00:00 AM" (varies by locale)
// Current timestamp in seconds
const now = Math.floor(Date.now() / 1000)Converting timestamps in Python
Python's datetime module uses the fromtimestamp() function (local time) or utcfromtimestamp() (UTC). For timezone-aware datetimes, use datetime.fromtimestamp(ts, tz=timezone.utc).
from datetime import datetime, timezone
ts = 1716240000 # seconds
# UTC datetime (naive)
dt_utc = datetime.utcfromtimestamp(ts)
print(dt_utc) # 2024-05-21 00:00:00
# Timezone-aware (recommended)
dt_aware = datetime.fromtimestamp(ts, tz=timezone.utc)
print(dt_aware) # 2024-05-21 00:00:00+00:00
# Current Unix timestamp
import time
print(int(time.time()))Common pitfalls
The year 2038 problem — 32-bit signed integers overflow at 2^31 - 1 = 2,147,483,647 (January 19, 2038). Modern 64-bit systems are not affected, but legacy embedded systems and old databases using INT(11) columns may be. Migrate to BIGINT for timestamp columns.
Timezone display errors — Timestamps are UTC internally. Displaying them requires converting to the user's timezone. Forgetting the conversion means users in different timezones see the wrong local time.
Daylight saving time — Timestamps themselves are immune to DST because they are UTC-based. Problems arise when you convert to/from local time without a proper timezone library.
Floating-point precision — Never store timestamps as IEEE 754 floats. Use integers (BIGINT in SQL, int in languages). Floats lose precision around the millisecond range for current timestamps.
Frequently asked questions
What is epoch time?
Epoch time is another term for Unix timestamp — the number of seconds elapsed since January 1, 1970, 00:00:00 UTC.
How do I convert a timestamp to a readable date online?
Paste the timestamp into MyDevTools Timestamp Converter and it instantly shows the UTC datetime, local datetime, relative time ("3 days ago"), and ISO 8601 format without any sign-in or install.
Why is my timestamp 1000x too large?
You likely have a millisecond timestamp where seconds are expected. JavaScript Date.now() returns milliseconds. Divide by 1000 to get seconds.
Is Unix time the same in every timezone?
Yes. Unix time is always counted from the UTC epoch, independent of timezone. The same Unix timestamp represents the same absolute moment everywhere on Earth.

