Both types hold a date and a time. timestamptz, short for timestamp with time zone, stores a moment: PostgreSQL converts it to UTC and shows it in your time zone. timestamp stores only the clock reading, and drops any time zone you give it. Here’s timestamp vs timestamptz in PostgreSQL, side by side in one table.
Every command and output on this page is real, from PostgreSQL 19 on macOS.
Syntax
Syntax
column_name timestamptz
column_name timestamp
timestamptz: a moment in time. It’s PostgreSQL’s short name fortimestamp with time zone.timestamp: a date and a clock time with no time zone, the same astimestamp without time zone.- Both take 8 bytes.
See Date/Time Types in the PostgreSQL documentation.
The Example
A team calendar stores when a meeting starts, once in each type. Then it looks at the same table from India and from London.
Step 1: Create a Test Database
Connect to your server with psql as the postgres user, as Part 2 of the PostgreSQL Tutorial shows. psql connects you to the postgres database, and its prompt is postgres=#.
Create a database for the example and connect to it:
postgres=#
CREATE DATABASE calendar;
Output
CREATE DATABASE
postgres=#
\c calendar
Output
You are now connected to database "calendar" as user "postgres".
Step 2: Create the Table
calendar=#
CREATE TABLE meetings (title text, starts_at timestamptz, starts_local timestamp);
Output
CREATE TABLE
Step 3: Save a Meeting in India’s Time Zone
SET TIME ZONE sets the time zone for your session only. Set it to India’s:
calendar=#
SET TIME ZONE 'Asia/Kolkata';
Output
SET
Then save a stand-up at 10:00 in both columns, and look at it:
calendar=#
INSERT INTO meetings (title, starts_at, starts_local) VALUES ('Stand-up', '2026-11-27 10:00', '2026-11-27 10:00');
Output
INSERT 0 1
calendar=#
SELECT * FROM meetings;
Output
title | starts_at | starts_local
----------+---------------------------+---------------------
Stand-up | 2026-11-27 10:00:00+05:30 | 2026-11-27 10:00:00
(1 row)
Both show 10:00. starts_at also shows the offset, +05:30.
Step 4: Look at It from London
calendar=#
SET TIME ZONE 'Europe/London';
Output
SET
calendar=#
SELECT * FROM meetings;
Output
title | starts_at | starts_local
----------+------------------------+---------------------
Stand-up | 2026-11-27 04:30:00+00 | 2026-11-27 10:00:00
(1 row)
starts_at now shows 04:30 London time, the same moment as 10:00 in India. starts_local still says 10:00, and nothing tells a reader in London that it meant 10:00 in India.
Step 5: Give a Time Zone in the Value
Save a review at 15:00 India time, with the offset written in the value:
calendar=#
INSERT INTO meetings (title, starts_at, starts_local) VALUES ('Review', '2026-11-27 15:00+05:30', '2026-11-27 15:00+05:30');
Output
INSERT 0 1
calendar=#
SELECT * FROM meetings;
Output
title | starts_at | starts_local
----------+------------------------+---------------------
Stand-up | 2026-11-27 04:30:00+00 | 2026-11-27 10:00:00
Review | 2026-11-27 09:30:00+00 | 2026-11-27 15:00:00
(2 rows)
starts_at converted it to London’s 09:30. starts_local threw the +05:30 away and kept 15:00, so nothing tells you it was India’s 15:00.
Which One to Use
- Use
timestamptzfor anything that happens at a moment: an order, a sign-up, a log entry. It’s right for everyone, wherever they are. - Use
timestamponly for a clock time that doesn’t belong to a time zone, and say so in the column name.
Clean Up
To remove the example, connect to another database and drop the test database:
calendar=#
\c postgres
Output
You are now connected to database "postgres" as user "postgres".
postgres=#
DROP DATABASE calendar;
Output
DROP DATABASE
Warning: DROP DATABASE deletes the database and everything in it, and it can’t be undone.
Common Mistakes
| Mistake | What happens | Do this instead |
|---|---|---|
timestamp for the moment something happened | A time zone in the value is silently dropped, as the review showed. | Use timestamptz. |
Expecting timestamptz to remember the time zone it was given | It stores the moment in UTC; the original time zone isn’t kept. | If you need the place, store its time zone name in a column of its own. |
FAQ
Does SET TIME ZONE change the server?
No, only your session. When you disconnect, the next session starts with the server’s own time zone again.
Does timestamptz take more space?
No. Both types take 8 bytes.
Conclusion
timestamptz stores a moment and shows it correctly in every time zone, as the stand-up showed in India and London. timestamp keeps only the clock reading and drops time zones without a word. For anything that happens, choose timestamptz.
Additional Resources
Related
- PostgreSQL Tutorial — Part 5: Data Types Explained
- Boolean and NULL in PostgreSQL: true, false and unknown
- How to Generate a UUID in PostgreSQL
Postgres, PostgreSQL and the Slonik Logo are trademarks or registered trademarks of the PostgreSQL Community Association of Canada, and used with their permission.
