Skip to main content
The TIMESTAMP and TIMESTAMPTZ store a date and time pair in UTC.

Variants

TIMESTAMP has two variants:
  • TIMESTAMP presents all TIMESTAMP values in UTC.
  • TIMESTAMPTZ converts TIMESTAMP values from UTC to the client’s session time zone (unless another time zone is specified for the value). However, it is conceptually important to note that TIMESTAMPTZ does not store any time zone data.
The default session time zone is UTC, which means that by default TIMESTAMPTZ values display in UTC.
The difference between these two variants is that TIMESTAMPTZ uses the client’s session , while the other simply does not. This behavior extends to functions like now() and extract() on TIMESTAMPTZ values.
A time zone offset of +00:00 is displayed for all and TIMESTAMP values, but is not stored in the database.
You can use the and functions to convert a TIMESTAMPTZ into a TIMESTAMP at a specified timezone, or to convert a TIMESTAMP into a TIMESTAMPTZ at a specified timezone. Explore the differences of TIMESTAMP and TIMESTAMPTZ in the following video: CREATE TABLE timestamps (a INT PRIMARY KEY, b TIMESTAMPTZ);

Create a table with a TIMESTAMP-typed column, with precision

To change the precision level of a column, you can use an statement:
When changing precision level, TIMESTAMP can be changed to TIMESTAMPTZ, and TIMESTAMPTZ can be changed to TIMESTAMP:
If a non-default precision level has already been specified, you cannot change the precision to a lower level. In this case, the b column, which is of type TIMESTAMPTZ(5), cannot be changed to a precision level below 5:

Convert a TIMESTAMP to seconds since epoch

Convert a TIMESTAMP to milliseconds since epoch

Convert a TIMESTAMP to microseconds since epoch

Convert an INT (seconds since epoch) to timestamp

Convert a STRING (seconds since epoch) to timestamp

Convert an INT (milliseconds since epoch) to timestamp

Note that TIMESTAMP epoch' is the equivalent of 0::timestamp.

Convert a STRING (milliseconds since epoch) to timestamp

Convert an INT (microseconds since epoch) to timestamp

Convert a STRING (microseconds since epoch) to timestamp

See also