TIMESTAMPTZ (timestamp with time zone)

Last updated: 2026-11-04

TIMESTAMPTZ (timestamp with time zone)

TIMESTAMPTZ denotes an absolute instant: it is stored internally as UTC and converted to local wall time according to the session's TimeZone setting when read, so the same value renders differently per session while always meaning the same moment. It is the correct default for "when did this happen" data, and a timestamptz column with DEFAULT now() records the insertion instant automatically.

Kindtype
Example LanguageSQL

📝 Syntax

TIMESTAMPTZ  |  TIMESTAMP WITH TIME ZONE  ——  8 bytes, stored as UTC internally
TIMESTAMPTZ(precision)  ——  specifies fractional-second precision

Returns:Stores an absolute instant (UTC internally). The rendered value depends on the session TimeZone; AT TIME ZONE 'Asia/Shanghai' converts it explicitly to a given local wall time.

▶ Example

Runs real PostgreSQL 18 right in your browser (PGlite WASM, nothing to install). Press ▶ Run and the result appears in the panel below.

Output:

 id |       created_at       |     in_shanghai     | epoch_seconds |         col_type
----+------------------------+---------------------+---------------+--------------------------
  1 | 2024-03-15 02:30:00+00 | 2024-03-15 10:30:00 |    1710469800 | timestamp with time zone

📌 Key Points

More case studies coming soon.

📚 Related Reference

❓ FAQ

QWhat does TIMESTAMPTZ actually store?
AA UTC instant (microseconds since 2000-01-01). The session time zone affects only display and input parsing. No local time information is stored, so changing zones never changes the meaning of the data.
QWhy does one column render differently in different clients?
ABecause each session has its own TimeZone. Pin the output with SET TimeZone = 'UTC', set it to 'Asia/Shanghai' for business-local display, or be explicit with AT TIME ZONE in the query.
Web-Tutorial.com

Web-Tutorial Tech Team

A team of developers maintaining programming tutorials. Each tutorial is written and reviewed by developers with expertise in that field. We work to keep our content accurate and reliable — if you spot an issue, please let us know.

Content reviewed by MOTO · Found an error? Report it

100%

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏