Epoch & Unix Timestamp Converter
Paste a unix epoch — seconds, milliseconds or microseconds are detected automatically — and get the UTC, ISO 8601 and local time instantly, or type a date to get its epoch back. Below the converter you get copy-ready SQL for the database side: PostgreSQL to_timestamp() for epoch-to-timestamptz, extract(epoch FROM ...) for the reverse, range filters on bigint epoch columns, a generated column that exposes epoch storage as a real timestamptz, and the MySQL equivalents. Everything runs in your browser.
Do more than epoch & unix timestamp converter — meet Chat2DB
Chat2DB is an AI-powered SQL client for Windows, macOS and Linux. Write SQL in natural language, format and optimize queries automatically, and manage MySQL, PostgreSQL, Oracle and 20+ other databases in one workspace.
How to use
- Paste an epoch value (e.g. 1700000000 or 1700000000000) — the unit is detected from its length and converted to UTC, ISO 8601 and your local time.
- Or enter a date like 2026-08-29 12:00:00 (interpreted as UTC) to get epoch seconds and milliseconds back.
- Copy the generated PostgreSQL / MySQL snippets to do the same conversion in SQL.
Frequently asked questions
How do I convert an epoch to a timestamp in PostgreSQL?
Use to_timestamp(): SELECT to_timestamp(1700000000) returns a timestamptz. The argument is double precision seconds, so pass milliseconds as to_timestamp(ms / 1000.0). To see the result in a fixed zone regardless of session settings, append AT TIME ZONE 'UTC', which yields a plain timestamp in UTC.
How do I get the unix timestamp from a date in PostgreSQL?
Use extract: SELECT extract(epoch FROM now())::bigint returns epoch seconds, and (extract(epoch FROM now()) * 1000)::bigint returns milliseconds. extract(epoch FROM ...) works on timestamp, timestamptz, date and interval values; for an interval it returns the total number of seconds in the interval.
Should I store timestamps as bigint epoch or timestamptz?
Prefer timestamptz: it is the same 8 bytes as bigint, is human-readable in every query, works with date arithmetic, intervals and time zone conversion, and indexes just as well. Use bigint epoch only when an external system dictates it — and consider a stored generated column with to_timestamp() so queries stay readable. To explore either format against a live database with AI-assisted SQL, try Chat2DB: download at https://chat2db.ai/download or use https://app.chat2db.ai.
