PostgreSQL 18 reference · Date and Time Functions

PostgreSQL TO_TIMESTAMP() Function

Convert Unix epoch seconds to a timestamp with time zone, or parse text into one with a format pattern.

PostgreSQL 18

Create a free account to save this page, take notes and track your progress. Sign in

Syntax

to_timestamp(seconds)  |  to_timestamp(text, format)

Parameters

ParameterDescription
seconds Unix time.
text, format Text and its pattern.

Return value

timestamp with time zone.

Examples

From Unix time
SELECT to_timestamp(1767225600) AS from_unix;

Output

       from_unix
------------------------
 2026-01-01 00:00:00+00
(1 row)

Run this on your computer — see “Get Started” for setup.

Parse text
SELECT to_timestamp('2026-03-09 7:45 PM', 'YYYY-MM-DD HH12:MI AM') AS parsed;

Output

         parsed
------------------------
 2026-03-09 19:45:00+00
(1 row)

Run this on your computer — see “Get Started” for setup.

Version history

VersionChange
PostgreSQL 17The TZ and OF patterns accept time zone abbreviations and offsets.

In other languages

Was this page helpful?