All Products
Search
Document Center

PolarDB:ST_TimeZone

Last Updated:Mar 28, 2026

Returns the IANA time zone name or GMT offset string for a given point.

Syntax

cstring ST_TimeZone(geometry point, boolean timezoneId, integer timezonePrecision);
cstring ST_TimeZone(geography point, boolean timezoneId, integer timezonePrecision);

Parameters

ParameterDescription
pointThe input point. Must be a point data type with spatial reference system WGS84 (SRID=4326).
timezoneIdControls the output format. true (default): returns an IANA time zone name (for example, Asia/Shanghai). false: returns a GMT offset string (for example, Etc/GMT+8).
timezonePrecisionThe lookup precision. Valid only when timezoneId is true. 16 (default): ~500 m precision. 21: ~20 m precision. Use 21 for points near time zone boundaries where a 500 m error could return the wrong time zone.

Return value

Returns a cstring containing the time zone string.

Background

Time zone boundary data comes from the Timezone Boundary Builder project.

Examples

Return an IANA time zone name (default behavior):

SELECT ST_TimeZone('SRID=4326;POINT(121 37)'::geometry);
-- Asia/Shanghai

SELECT ST_TimeZone('POINT(60 37)'::geography);
-- Asia/Tehran

Return a GMT offset string:

SELECT ST_TimeZone('SRID=4326;POINT(121 37)'::geometry, false);
-- Etc/GMT+8

Use higher precision for a point near a time zone boundary:

SELECT ST_TimeZone('SRID=4326;POINT(-121 37)'::geometry, true, 21);
-- America/Los_Angeles

Pass a longitude greater than 180°:

SELECT ST_TimeZone(('SRID=4326;POINT(400 37)'::geometry));
-- Europe/Istanbul