Obtains the time zone information of a point object.
Syntax
cstring ST_TimeZone(geometry point, boolean timezoneId, integer timezonePrecision);
cstring ST_TimeZone(geography point, boolean timezoneId, integer timezonePrecision);
Parameters
Parameter | Description |
point | The geometry object. It must meet the following requirements:
|
timezoneId | Specifies whether to return the time zone in the name format. Valid values:
|
timezonePrecision | The data precision of the time zone. This parameter is valid when the timezoneId parameter is set to true. Valid values:
|
Return values
The time zone string is returned.
Description
Obtains the time zone information of a point object. The geographical boundary data of time zones is obtained from the Timezone Boundary Builder project.
Examples
SELECT ST_TimeZone('SRID=4326;POINT(121 37)'::geometry);
----
Asia/Shanghai
SELECT ST_TimeZone('POINT(60 37)'::geography);
----
Asia/Tehran
-- A simple time zone string is returned.
SELECT ST_TimeZone('SRID=4326;POINT(121 37)'::geometry, false);
----
Etc/GMT+8
-- The data precision is required.
SELECT ST_TimeZone('SRID=4326;POINT(-121 37)'::geometry, true, 21);
----
America/Los_Angeles
-- The longitude must be greater than 180°.
SELECT ST_TimeZone(('SRID=4326;POINT(400 37)'::geometry));
----
Europe/Istanbul