mamluk/geo-tz

Find the timezone at a specific GPS coordinate (PHP port of node-geo-tz)

Maintainers

Details

1x.ax/mamluk/library/geo-tz

Installs: 27

Dependents: 0

Suggesters: 0

Security: 0

pkg:composer/mamluk/geo-tz

0.2.1 2026-01-30 10:37 UTC

This package is not auto-updated.

Last update: 2026-01-30 10:38:18 UTC


README

A PHP 8.2+ port of the node-geo-tz public API for finding the timezone at a GPS coordinate.

Original project: node-geo-tz by Evan Siroky (https://github.com/evansiroky/node-geo-tz).

Install

composer require mamluk/geo-tz

Usage

Default dataset (1970 timezones):

use GeoTz\GeoTz;

$tzids = GeoTz::find(47.650499, -122.35007);

// Optional: preload all features into memory
GeoTz::preCache();

// Optional: control caching
GeoTz::setCache(['preload' => true]);

// Optional: provide a Symfony cache pool or PSR-16 cache
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
use Symfony\Component\Cache\Psr16Cache;

$pool = new FilesystemAdapter('geo_tz');
GeoTz::setCache(['store' => $pool]);

$psr16 = new Psr16Cache($pool);
GeoTz::setCache(['store' => $psr16]);

Full dataset (all timezones):

use GeoTz\All\GeoTz as AllGeoTz;

$tzids = AllGeoTz::find(12.826174, 45.036933);

"Now" dataset (latest distinct zones):

use GeoTz\Now\GeoTz as NowGeoTz;

$tzids = NowGeoTz::find(12.826174, 45.036933);

Data updates

The data files are vendored under data/. To refresh them from the upstream node-geo-tz GitHub repository:

composer update-data

This downloads the latest data files from the master branch and writes data/SOURCE.json with the commit SHA and timestamps.

Environment

Set GEO_TZ_DATA_PATH to point at an alternate directory containing the *.geo.dat files if you want to store them outside the package.