LOCAL_TO_UTC()
All functions > DATE AND TIME > LOCAL_TO_UTC()
Converts a local clock time (TIMESTAMPTZ) in the given zone to a UTC TIMESTAMP.
Signatures
Returns: UTC timestamp for that local time
LOCAL_TO_UTC(timestamp: TIMESTAMPTZ, timezone: VARCHAR) → TIMESTAMP sql
| Parameter | Type | Required | Description |
|---|---|---|---|
timestamp | TIMESTAMPTZ | Yes | Local clock time in the named zone |
timezone | VARCHAR | Yes | 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 local time (TIMESTAMPTZ). To read the fields of a TIMESTAMP as local time, wrap it in CAST(… AS TIMESTAMPTZ): the cast changes the type only, not the clock.
- The zone is not stored in a TIMESTAMPTZ; pass the zone the value is local to.
- Accepts the same timezone names as UTC_TO_LOCAL()
- Note: the sign in 'Etc/GMT±N' is POSIX-inverted — 'Etc/GMT-2' means UTC+2
- Propagates NULL when the timestamp is NULL
- Presentation of a UTC-stored instant in a zone uses UTC_TO_LOCAL()
Examples
FeatureQL
RETURN
-- Local Paris wall time → UTC (CET = UTC+1 in March)
f1 := LOCAL_TO_UTC(
MAKE_TIMESTAMP(
ROW(
2024 AS year,
3 AS month,
15 AS day,
14 AS hour,
30 AS minute,
45 AS second
)
)::TIMESTAMPTZ(3),
'Europe/Paris'
)
;Result
| f1 TIMESTAMP |
|---|
| 2024-03-15T13:30:45 |
On this page