All Products
Search
Document Center

PolarDB:ST_TimeZone

Last Updated:Dec 04, 2024

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:

  • It is of point data type.

  • Its spatial reference system is WGS84(srid=4326).

timezoneId

Specifies whether to return the time zone in the name format. Valid values:

  • true (default): returns the time zone in the name format. Example: Asia/Shanghai.

  • false, the time zone in the standard GMT format. Example: Etc/GMT+8.

timezonePrecision

The data precision of the time zone. This parameter is valid when the timezoneId parameter is set to true. Valid values:

  • 16 (default): The precision is 0.0055 (~500m).

  • 21: The precision is 0.00017 (~20m).

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