AT TIME ZONE converts timestamp or timestamptz values between time zones in ParadeDB/PostgreSQL-compatible databases.
Applications often store all timestamps in UTC but must display local times to users. ParadeDB inherits PostgreSQL’s rich time-zone functions, letting you shift timestamps on the fly without duplicating data.
Use the AT TIME ZONE
construct or the timezone()
function.Both accept any valid IANA time-zone string such as 'America/New_York'
or offsets like '+02'
.
• timestamp AT TIME ZONE zone → timestamptz
• timestamptz AT TIME ZONE zone → timestamp
The operator converts to or from UTC automatically based on the data type.
Retrieve Orders.order_date
(stored as timestamptz
in UTC) and show it in Pacific Time:
SELECT id,
order_date AT TIME ZONE 'America/Los_Angeles' AS order_date_pt
FROM Orders;
If a UI sends “2024-05-01 09:00” in the user’s zone, cast to timestamp
and attach the zone:
INSERT INTO Orders (customer_id, order_date, total_amount)
VALUES (42, ('2024-05-01 09:00'::timestamp AT TIME ZONE 'America/Los_Angeles'), 129.99);
Store all times as timestamptz
in UTC.Convert only for display. Always use named zones, not numeric offsets, because offsets change with daylight-saving rules.
See below for pitfalls and fixes.
ParadeDB follows PostgreSQL docs for AT TIME ZONE
and timezone()
. Review them for advanced tricks like interval arithmetic and indexing.
.
Yes. ParadeDB ships with the same IANA time-zone database as PostgreSQL, so any name in pg_timezone_names
works.
You can create a generated column with the converted value and index that column, improving queries that filter by local time ranges.
Run SET TIME ZONE 'America/Los_Angeles';
. Subsequent inputs lacking zone info will be interpreted in that zone.