How to Convert a Unix Timestamp to a Human-Readable Date
Convert Unix timestamps to readable dates in JavaScript, Python, bash, SQL, and Excel. Avoid timezone traps with our free Unix timestamp converter tool.
The Two-Direction Problem
You see 1716998400 in a log file, an API response, or a database column. Is
that last week? Last month? Next year? You need a date you can read. Conversely,
you have a human date and need to express it as a timestamp for code.
The Unix Timestamp Converter handles both directions in a browser. Below are the code approaches for when you need it in a script.
Timestamp to Human-Readable Date
JavaScript
// Seconds to ISO string
new Date(1700000000 * 1000).toISOString();
// "2023-11-14T22:13:20.000Z"
// Seconds to local string
new Date(1700000000 * 1000).toLocaleString();
// "11/14/2023, 2:13:20 PM" (depends on locale/timezone)
// Milliseconds (13-digit) to ISO string
new Date(1700000000000).toISOString();
// "2023-11-14T22:13:20.000Z"
// Custom format without a library
const d = new Date(1700000000 * 1000);
const iso = d.getFullYear() + '-' +
String(d.getMonth() + 1).padStart(2, '0') + '-' +
String(d.getDate()).padStart(2, '0');
// "2023-11-14"
JavaScript Date expects milliseconds. Multiply second-based timestamps by
1000. For 13-digit timestamps (milliseconds), pass them directly. A common bug:
passing a 10-digit timestamp to new Date() without multiplying treats it as
milliseconds, returning a date in 1970.
Python
from datetime import datetime, timezone
# Seconds to UTC datetime
dt = datetime.fromtimestamp(1700000000, tz=timezone.utc)
# datetime.datetime(2023, 11, 14, 22, 13, 20)
# Formatted string
dt.strftime("%Y-%m-%d %H:%M:%S")
# "2023-11-14 22:13:20"
# Milliseconds
datetime.fromtimestamp(1700000000000 / 1000, tz=timezone.utc)
# ISO 8601 format with timezone
dt.isoformat()
# "2023-11-14T22:13:20+00:00"
# Local timezone
from datetime import datetime
datetime.fromtimestamp(1700000000)
# Uses system local timezone
Always pass tz=timezone.utc to fromtimestamp. Without it, Python applies
the system's local timezone. On a server set to UTC, this works fine. On your
laptop set to EST, you get a time 5 hours off.
Bash
# Convert timestamp to date (GNU date, Linux)
date -d @1700000000
# Tue 14 Nov 2023 10:13:20 PM UTC
# With custom format
date -d @1700000000 "+%Y-%m-%d %H:%M:%S"
# 2023-11-14 22:13:20
# macOS/BSD date uses -r instead of -d @
date -r 1700000000
The -d @ syntax is GNU-specific. macOS and BSD use -r. To write portable
shell scripts, check which date is available or use Python/Perl for timestamp
conversion.
SQL
-- PostgreSQL
SELECT to_timestamp(1700000000);
-- 2023-11-14 22:13:20+00
-- MySQL
SELECT FROM_UNIXTIME(1700000000);
-- 2023-11-14 22:13:20
-- SQLite
SELECT datetime(1700000000, 'unixepoch');
-- 2023-11-14 22:13:20
-- SQL Server
SELECT DATEADD(second, 1700000000, '1970-01-01');
-- 2023-11-14 22:13:20.000
SQL Server does not have a built-in FROM_UNIXTIME equivalent. You add the
seconds to the epoch. For millisecond timestamps, use DATEADD(millisecond, ...)
or divide by 1000 first.
Excel / Google Sheets
# Excel (seconds)
=DATE(1970,1,1) + (1700000000 / 86400)
# Excel (milliseconds)
=DATE(1970,1,1) + (1700000000000 / 86400000)
# Google Sheets
=EPOCHTODATE(1700000000)
Excel stores dates as days since January 1, 1900 (Windows) or January 1, 1904 (Mac). Divide your timestamp by 86,400 (seconds per day) and add to the epoch date. Format the cell as a date/time to see the result.
Human Date to Timestamp
JavaScript
// Seconds
Math.floor(new Date("2026-08-05T12:00:00Z").getTime() / 1000);
// With Date.UTC for explicit UTC
Date.UTC(2026, 7, 5, 12, 0, 0) / 1000;
// Month is 0-indexed: 7 = August
Python
import calendar, datetime
dt = datetime.datetime(2026, 8, 5, 12, 0, 0, tzinfo=datetime.timezone.utc)
calendar.timegm(dt.timetuple())
# Or with Python 3.3+
int(dt.timestamp())
Bash
date -d "2026-08-05 12:00:00 UTC" +%s
SQL
-- PostgreSQL
SELECT EXTRACT(EPOCH FROM '2026-08-05 12:00:00+00'::timestamptz);
-- MySQL
SELECT UNIX_TIMESTAMP('2026-08-05 12:00:00');
Timezone Traps
The single most common mistake when converting timestamps is timezone confusion.
A Unix timestamp is always UTC. Always. 1700000000 represents the same
instant everywhere in the universe. The local time you display depends on your
timezone, but the timestamp itself does not.
When you convert 1700000000 to a local date string in New York, you get
November 14, 2023 at 5:13 PM EST. In Tokyo, you get November 15, 2023 at 7:13 AM JST. Both are correct representations of the same instant.
The bug: storing a local time as a Unix timestamp without conversion. If you
take "2026-08-05 12:00:00 EST" and call Date.parse() without specifying UTC,
JavaScript applies the local timezone. The resulting timestamp is wrong by the
UTC offset. Always parse as UTC or store the timezone alongside the timestamp.
Another trap: daylight saving time. If your server local timezone observes DST,
datetime.fromtimestamp() produces different UTC offsets depending on the
date. A timestamp from July and a timestamp from January get different UTC
offsets when formatted locally. This wrecks date comparison logic. Always work
in UTC and convert to local timezone only at the display layer.
Try it yourself: open the Unix Timestamp Converter. Enter the current timestamp (from
date +%s) and verify the displayed date matches your current time. Then enter a timestamp from a production log and see when the event occurred. Pick a future date and get its timestamp for use in a script.