UTC_TO_LOCAL()
All functions > DATE AND TIME > UTC_TO_LOCAL()
Converts a UTC TIMESTAMP to the local clock time in the given timezone (TIMESTAMPTZ).
Signatures
Returns: Local clock time in the target zone (the zone is not stored in the value)
UTC_TO_LOCAL(timestamp: TIMESTAMP, timezone: VARCHAR) → TIMESTAMPTZ sql
| Parameter | Type | Required | Description |
|---|---|---|---|
timestamp | TIMESTAMP | Yes | UTC timestamp |
timezone | VARCHAR | Yes | Target IANA timezone name ('Europe/Paris') or fixed-offset name ('Etc/GMT-2' for UTC+2; sign is POSIX-inverted) |
Notes
- The first argument must be a UTC TIMESTAMP; a TIMESTAMPTZ is already a local time.
- TIMESTAMP is UTC and TIMESTAMPTZ is local time. The zone is not stored in a TIMESTAMPTZ: pass the same zone to LOCAL_TO_UTC() to convert back.
- Accepts IANA timezone names ('Europe/Paris', 'America/New_York') or fixed-offset names ('Etc/GMT-2' for UTC+2, 'Etc/GMT+5' for UTC-5)
- Note: the sign in 'Etc/GMT±N' is POSIX-inverted — 'Etc/GMT-2' means UTC+2
- The return type is TIMESTAMPTZ(3)
- Propagates NULL: if the input is NULL the result is NULL
- Inverse direction (local time → UTC) uses LOCAL_TO_UTC()
- Interval arithmetic on a TIMESTAMPTZ is not supported: convert to UTC first
Examples
FeatureQL
RETURN
-- UTC to Paris (CET, UTC+1 in March)
f1 := UTC_TO_LOCAL(TIMESTAMP '2024-03-15 09:50:00', 'Europe/Paris'),
-- UTC to New York (EDT, UTC-4 in March)
f2 := UTC_TO_LOCAL(TIMESTAMP '2024-03-15 09:50:00', 'America/New_York'),
-- NULL propagates
f3 := UTC_TO_LOCAL(NULL::TIMESTAMP, 'Europe/Paris')
;Result
| f1 TIMESTAMP | f2 TIMESTAMP | f3 TIMESTAMP |
|---|---|---|
| 2024-03-15T10:50:00 | 2024-03-15T05:50:00 | NULL |
On this page