PHPackages                             abdalasif/geo-timezone - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. abdalasif/geo-timezone

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

abdalasif/geo-timezone
======================

PHP library for timezone calculation from a particular location and date.

0179PHP

Since Sep 3Pushed 1y ago1 watchersCompare

[ Source](https://github.com/abdalasif/geo-timezone)[ Packagist](https://packagist.org/packages/abdalasif/geo-timezone)[ RSS](/packages/abdalasif-geo-timezone/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Geo-Timezone PHP Library
========================

[](#geo-timezone-php-library)

[![Build Status](https://camo.githubusercontent.com/a6652a143446b174ed628e31cbdcdd30c2ed8c3e19e5d63f0cb5423a651fc333/68747470733a2f2f7472617669732d63692e6f72672f6d696e7562652f67656f2d74696d657a6f6e652e706e67)](https://travis-ci.org/minube/geo-timezone) [![Code Coverage](https://camo.githubusercontent.com/1773142622cea5dacee8b55e12931d854b6aa3ce862272185572b5058d4a5c84/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d696e7562652f67656f2d74696d657a6f6e652f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/minube/geo-timezone/?branch=master) [![Scrutinizer Code Quality](https://camo.githubusercontent.com/5db77b0a5233cc41fa9d2fb312085a3162e41b25bbb33675c83a54420ba21d29/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d696e7562652f67656f2d74696d657a6f6e652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/minube/geo-timezone/?branch=master) [![Build Status](https://camo.githubusercontent.com/58036dd67aa4c0d149591fdf780ef0c870ec37a131daa908e6a8f4e79b59006d/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d696e7562652f67656f2d74696d657a6f6e652f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/minube/geo-timezone/build-status/master)

Based on the [node-geo-tz package](https://github.com/evansiroky/node-geo-tz), this PHP library calculates the timezone associated to a particular location based on coordinates (latitude, longitude) and timestamp reference. Therefore, this library provides the local date of a particular location in any moment too. In addition, it is based on the timezones boundaries extracted by [timezone-boundary-builder](https://github.com/evansiroky/timezone-boundary-builder) tool, so it is necessary to always use the latest version of this package. In order to improve the timezone search through the boundaries, node-geo-tz proposes to create a tree of directories based on dividing the Earth in quadrants and sub-quadrants iteratively. This tree is called "data.zip" in the reference library.

Requirements
------------

[](#requirements)

GEOS PHP extension is needed to run library. So, you should download and compile it running the script bin/compile-geos .sh; then, the library called "geos.so" will be added to /usr/lib/php. As you can see, this script contains the installation of some php extensions that will be necessary in the next step of the installation process.

Once you have compiled the GEOS PHP extension, you should create the file geos.ini in order to enable the module and improve the performance consequently.

Finally, you should run the composer file, so the rest of necessary libraries will be installed.

Usage
-----

[](#usage)

There are two main classes:

- UpdaterData: script that downloads the last version of the timezone boundaries data and creates the tree of directories (data.zip). It takes a few hours, so you can use "data.zip" from node-geo-tz to test for the first time. Otherwise, you can run the UpdaterData script in order to get the last version and create the directories tree. Destination folder must have write permisions

```
    use GeoTimeZone\UpdaterData;

    $updater = new UpdaterData("/path/to/data/");
    $updater->updateData();
```

- Calculator: provides the timezone name or the local date associated to a particular latitude, longitude and timestamp.

```
    use GeoTimeZone\Calculator;

    $latitude = 39.452800;
    $longitude = -0.347038;
    $timestamp = 1469387760;

    $calculator = new Calculator("/path/to/data/");

    // Local date
    $localDate = $calculator->getLocalDate($latitude, $longitude, $timestamp);
    /* DateTime Object
    (
        [date] => 2016-07-24 21:16:00.000000
        [timezone_type] => 3
        [timezone] => Europe/Madrid
    )
    */

    // TimeZone name
    $timeZoneName = $calculator->getTimeZoneName($latitude, $longitude);
    //Europe/Madrid
```

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance29

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity17

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/99a8e3c58c7ea183247aa5360d183a19d2a63ce90cf496f5c5aa131caf763010?d=identicon)[abdalasif](/maintainers/abdalasif)

---

Top Contributors

[![abdalasif](https://avatars.githubusercontent.com/u/52707245?v=4)](https://github.com/abdalasif "abdalasif (1 commits)")

### Embed Badge

![Health badge](/badges/abdalasif-geo-timezone/health.svg)

```
[![Health](https://phpackages.com/badges/abdalasif-geo-timezone/health.svg)](https://phpackages.com/packages/abdalasif-geo-timezone)
```

###  Alternatives

[bertptrs/phpstreams

A streams library for PHP based on the Java 8 Streams API.

883.2k](/packages/bertptrs-phpstreams)[cheprasov/php-parallel

The class allows you to run multiple operations parallel in different processes and send results to the main process. Useful if you need to run multiple independent operations simultaneously, instead of sequential execution, or if you run several independent queries, for example, queries to different data bases

1712.5k5](/packages/cheprasov-php-parallel)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
