LOCAL_TO_UTC()
All functions > DATE AND TIME > LOCAL_TO_UTC()
Treats a naive TIMESTAMP as local wall time in the given zone and returns the same instant as a naive UTC TIMESTAMP.
Signatures
Returns: UTC wall time for that instant (naive TIMESTAMP)
LOCAL_TO_UTC(timestamp: TIMESTAMP, timezone: VARCHAR) → TIMESTAMP sql
| Parameter | Type | Required | Description |
|---|---|---|---|
timestamp | TIMESTAMP | Yes | Naive TIMESTAMP whose fields are local wall 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 naive TIMESTAMP (not TIMESTAMPTZ); pair with MAKE_TIMESTAMP() when building from calendar parts.
- 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
SELECT
-- 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
)
),
'Europe/Paris'
),
-- Local New York wall time → UTC (EDT, UTC-4 in March)
f2 := LOCAL_TO_UTC(TIMESTAMP '2024-03-15 14:30:00', 'America/New_York'),
-- NULL propagates
f3 := LOCAL_TO_UTC(NULL(TIMESTAMP), 'Europe/Paris')
;Result
| f1 TIMESTAMP | f2 TIMESTAMP | f3 TIMESTAMP |
|---|---|---|
| 2024-03-15T13:30:45 | 2024-03-15T18:30:00 | NULL |
On this page