Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: Views Bootstrap 5.5.4 — Minor update available for module views_bootstrap (5.5.4). Release: Rightup theme 1.0.3 — Minor update available for theme vartheme_bs5_rightup (1.0.3). Release: CommentOn 1.0.6 — Minor update available for module commenton (1.0.6). Release: ChatGPT Ads 1.0.3 — Minor update available for module chatgpt_ads (1.0.3). Release: Opensolr Search 5.1.3 — Minor update available for module opensolr_search (5.1.3). Release: ServiceM8 Webform Integration 1.2.1 — Minor update available for module servicem8_webform (1.2.1). Release: PostfixAdmin 1.0.0 — Initial release available for module postfix_admin (1.0.0)! Release: ip_analyser 1.0.3 — Minor update available for module ip_analyser (1.0.3). Module Revived: Swagger-PHP OpenAPI 3 documentation generator 1.0.0 — Module swagger_php updated after 10 months of inactivity (1.0.0). Security Coverage: Microsoft Azure AI — Module ai_provider_azure now has official Drupal security advisory coverage.

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).

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 Release date
4.0.0-alpha1 Pre-release Mar 4, 2023
4.0.x-dev Dev Mar 4, 2023