How to Convert a Unix Timestamp to a Date
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:
new Date(1700000000 * 1000).toISOString();
// "2023-11-14T22:13:20.000Z"
Python
from datetime import datetime, timezone
datetime.fromtimestamp(1700000000, tz=timezone.utc)
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 config file to check?
Open the config toolkit →