Skip to main content
drupalreleases

Use direct release data with your AI assistant.

Learn more

Geo Time Zone

Security covered Under active development 99 sites

This module provides an API to determine the time zone based on geographic location, supporting lookups by coordinates, region, or country. It returns the time zone identifier and its UTC/GMT offset.

API that determines the time zone based on geo location (coordinates or region or country). Using "geotimezone_query($location, $format);" that returns time zone identifier or UTC/GMT offset or both (depends on $format value). Where the first parameter is an associative array with array keys of:

longitude
latitude
regionCode
region
countryCode

To determine the time zone based on coordinates, the 'longitude' and 'latitude' keys are required to have valid coordinates values. E.g.

geotimezone_query([
  'latitude'  => '14.5995',
  'longitude' => '120.9842',
]);

... will return:

Array
(
  [identifier] => Asia/Manila
  [offset] => +08:00
)

To determine the time zone based on region, the 'countryCode' and either of 'regionCode' or 'region' are required. E.g.

geotimezone_query([
  'region'      => 'Quezon City',
  'countryCode' => 'PH',
]);

... will return:

Array
(
  [identifier] => Asia/Manila
  [offset] => +08:00
)

To determine the time zone based on country, the 'countryCode' is required. E.g.

geotimezone_query([
  'countryCode' => 'AU',
]);

... will return:

Array
(
  [identifier] => Array
    (
      [0] => Australia/Darwin
      [1] => Australia/Lindeman
      [2] => Australia/Brisbane
      [3] => Australia/Lord_Howe
      [4] => Australia/Eucla
      [5] => Australia/Perth
      [6] => Australia/Broken_Hill
      [7] => Australia/Sydney
      [8] => Australia/Adelaide
      [9] => Australia/Melbourne
      [10] => Australia/Currie
      [11] => Australia/Hobart
    )
  [offset] => Array
    (
      [0] => +09:30
      [1] => +10:00
      [2] => +10:00
      [3] => +10:30
      [4] => +08:45
      [5] => +08:00
      [6] => +09:30
      [7] => +10:00
      [8] => +09:30
      [9] => +10:00
      [10] => +10:00
      [11] => +10:00
    )
)

If all keys are present, the coordinates (longitude/latitude) are the query's priority (the rest will be ignored). The region is the next query's priority if coordinates are not present. And the country is the last priority if coordinates and region are not present.
It is recommended to provide coordinates for accurate time zone while region is the next accurate and the least is the country where it may return multiple time zones in array.

This module does not need web services, data files or SQL database. This is a Drupal version of LatLongToTimezone project (https://github.com/drtimcooper/LatLongToTimezone).

Ask your assistant about Geo Time Zone

Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
2
Tracked since
Mar 2023
Latest release
3 years ago
Releases (12 mo)
0
Maintenance
Dormant

Releases

Version Type Core PHP Release date
4.0.0-alpha1 Pre-release 9–10 Mar 4, 2023
4.0.x-dev Dev 8–9 Mar 4, 2023