Convert a Unix Timestamp in SQL
Convert Unix timestamps to dates in MySQL with FROM_UNIXTIME and in PostgreSQL with to_timestamp. Verify the expected value with the converter.
Part of the free Unix Timestamp Converter. Runs in your browser — nothing is uploaded.
Convert a Unix Timestamp in SQL
MySQL uses FROM_UNIXTIME(ts) and PostgreSQL uses to_timestamp(ts) to turn epoch seconds into a date. Both depend on the session timezone, so check your expected UTC value with the converter first.
Worked example: Expected value when the session timezone is UTC
SQL
SELECT FROM_UNIXTIME(1700000000); -- MySQL SELECT to_timestamp(1700000000); -- PostgreSQL
Result (UTC session)
2023-11-14 22:13:20 (MySQL) 2023-11-14 22:13:20+00 (PostgreSQL)
Practical tip
Set the session timezone to UTC when comparing results, for example SET time_zone = '+00:00' in MySQL or SET TIME ZONE 'UTC' in PostgreSQL.
How to use this Unix Timestamp
- 1Use the live tool above — it runs entirely in your browser and never uploads your data.
- 2Paste the sample from the worked example, or use your own input.
- 3Copy the result, then adapt the same steps in your editor, script, or pipeline.
Convert a Unix Timestamp in SQL FAQs
How do I get an epoch from a date in SQL?
MySQL: UNIX_TIMESTAMP(date_col). PostgreSQL: EXTRACT(EPOCH FROM date_col). Both return seconds since 1970-01-01 UTC.
Why does FROM_UNIXTIME show a different hour?
It formats in the session timezone. If the server is not on UTC, the displayed hour differs from the UTC value.
More Unix Timestamp pages
- Epoch to Date ConverterConvert an epoch or Unix timestamp to a readable date and time. Paste seconds or milliseconds and get UTC and local time instantly.
- Convert a Date to a Unix TimestampConvert a calendar date and time to a Unix timestamp in seconds. Enter a date, choose a timezone and copy the epoch value.
- Milliseconds Timestamp to DateConvert a 13-digit millisecond Unix timestamp to a readable date. Works for JavaScript Date.now() and Java System.currentTimeMillis() values.
- Current Unix TimestampGet the current Unix timestamp in seconds and milliseconds. See how to read epoch time now in JavaScript, Python, Bash and SQL.
- Convert Epoch to UTCConvert an epoch timestamp to a UTC date and time. See the ISO 8601 string and avoid local-timezone confusion when reading logs.
- What Date Is Unix Timestamp 1000000000?Unix timestamp 1000000000 is the "billennium": the moment epoch time reached one billion seconds. See the exact date and how to convert any timestamp.
- Year 2038 Problem and Timestamp 2147483647Timestamp 2147483647 is the largest 32-bit signed Unix time. Convert it to see the date and learn how to avoid the Year 2038 problem.
- Unix Timestamp to ISO 8601Convert a Unix timestamp to an ISO 8601 string like 2026-01-01T00:00:00Z. Ideal for APIs, JSON payloads and logging formats.
- Convert a Unix Timestamp to a Date in JavaScriptConvert a Unix timestamp to a Date in JavaScript with new Date(ts * 1000). Check your result with the live converter and avoid the seconds vs milliseconds trap.