Blog

How to Convert a Unix Timestamp to a Date

Convert a Unix timestamp to a human-readable date in JavaScript, Python, SQL, and online — plus the seconds-vs-milliseconds gotcha.

A Unix timestamp is just a number of seconds. Turning it into a readable date is quick in any language.

Online

The fastest way is the timestamp converter — paste the number, get the UTC and local date instantly (and convert back).

JavaScript

Date expects milliseconds, so multiply a seconds-based timestamp by 1000:

js
new Date(1700000000 * 1000).toISOString();
// "2023-11-14T22:13:20.000Z"

Python

python
from datetime import datetime, timezone
datetime.fromtimestamp(1700000000, tz=timezone.utc)

SQL

sql
-- PostgreSQL
SELECT to_timestamp(1700000000);

-- MySQL
SELECT FROM_UNIXTIME(1700000000);

The seconds vs milliseconds trap

The number one bug: passing a seconds timestamp where milliseconds are expected (or vice versa). You'll get a date in 1970 or far in the future.

  • 10 digits → seconds
  • 13 digits → milliseconds

Going the other way

To get the current timestamp: Math.floor(Date.now() / 1000) in JS. The converter also turns a date back into a timestamp.

Got a file to check?
Paste it in. Errors come back in plain English.
Open Unix Timestamp Converter →