PHPackages                             wyndow/teazee - 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. wyndow/teazee

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

wyndow/teazee
=============

A simple interface to determine the timezone and time offset data for a location on the earth.

0.3.0(10y ago)1665[1 issues](https://github.com/wyndow/teazee/issues)MITPHPPHP &gt;=5.5

Since Nov 18Pushed 10y ago1 watchersCompare

[ Source](https://github.com/wyndow/teazee)[ Packagist](https://packagist.org/packages/wyndow/teazee)[ RSS](/packages/wyndow-teazee/feed)WikiDiscussions develop Synced 2mo ago

READMEChangelog (3)Dependencies (6)Versions (7)Used By (0)

Teazee
------

[](#teazee)

[![License](https://camo.githubusercontent.com/d774222c0d4afacde6a1b64204732d120c49e54b56a26134219ed0f28d599b11/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f77796e646f772f7465617a65652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/wyndow/teazee) [![Build Status](https://camo.githubusercontent.com/25db918e7f2f0c39444853057455f38d279a9b3c208c3f216f3f6e7c0bfd2e30/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f77796e646f772f7465617a65652e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/wyndow/teazee) [![Code Quality](https://camo.githubusercontent.com/f6243e4fde473890a69e08240bec6f37053fc69d21e67d16d98714b303517144/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f77796e646f772f7465617a65652e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/wyndow/teazee/) [![Code Coverage](https://camo.githubusercontent.com/474fd01999af80995724093aae71bd67f1f1cef49de36b4786c34dcd7b3c3a25/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f77796e646f772f7465617a65652e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/wyndow/teazee/) [![Package Version](https://camo.githubusercontent.com/9a143d05b05dcf5c0bd24a249d01ae7480e07d2ddffc99a878995ad2e7dd45d5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f77796e646f772f7465617a65652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/wyndow/teazee)

A simple interface to find the timezone and time offset data for a position on the surface of the earth.

- [Installation](#installation)
- [Usage](#usage)
    - [ZoneInfo](#zoneinfo)
    - [Providers](#providers)
        - [Google Maps](#google-maps)
        - [TimezoneDb](#timezonedb)
    - [The Chain Provider](#the-chain-provider)
    - [HTTP Clients](#http-clients)
- [Extending Things](#extending-things)
- [Versioning](#versioning)

Installation
------------

[](#installation)

The recommended way to install Teazee is through [Composer](http://getcomposer.org):

```
$ composer require wyndow/teazee

```

Usage
-----

[](#usage)

The `Teazee` interface, which all providers implement, exposes a single method:

- `find($lat, $lng, $timestamp = null)`

### ZoneInfo

[](#zoneinfo)

The `find()` method returns a `ZoneInfo` object, which extends PHP's [`DateTimeZone`](http://php.net/manual/en/class.datetimezone.php) and exposes the following additional methods:

- `getDateTime()` will return a [`DateTimeImmutable`](http://php.net/manual/en/class.datetimeimmutable.php) representing the specified `timestamp`.
- `getTimestamp()` will return a UNIX timestamp (`int`) for the specified `timestamp`. Generally this value is used to determine whether or not Daylight Savings Time should be applied. Not all providers require a timestamp. If the timestamp is required, but not provided, the current time will be used.
- `getUtcOffset()` will return the offset (`int`) from UTC (in seconds) for the given location.
- `isDst()` will return a `boolean` representing whether or not the timezone is in Daylight Savings Time during the specified `timestamp`.
- `getCountry()` will return the 2-digit country code for the timezone.

> **Note**: You can use `ZoneInfo` as a drop-in replacement for `DateTimeZone` in your code.

### Providers

[](#providers)

Providers perform the black magic for you: talking to the APIs, fetching results, dealing with errors, etc.

#### Google Maps

[](#google-maps)

[Get a Key](https://developers.google.com/maps/documentation/timezone/get-api-key)

The [Google Maps TimeZone API](https://developers.google.com/maps/documentation/timezone/intro) will allow you to make a number of calls without authenticating.

```
$teazee = new Teazee\Provider\GoogleMaps(null, $client, $messageFactory);
```

When you're ready to use your own API key, pass it as a first argument:

```
$teazee = new Teazee\Provider\GoogleMaps($apiKey, $client, $messageFactory);
```

#### TimeZoneDB

[](#timezonedb)

[Get a Key](https://timezonedb.com/register)

A valid `apiKey` is required to use the [TimeZoneDB](https://timezonedb.com) provider.

```
$teazee = new Teazee\Provider\TimezoneDb($apiKey, $client, $messageFactory);
```

If you have a premium account with TimezoneDb, pass `true` as the second argument to use the VIP endpoint.

```
$iAmVIP = true;
$teazee = new Teazee\Provider\TimezoneDb($apiKey, $iAmVIP, $client, $messageFactory);
```

### The Chain Provider

[](#the-chain-provider)

The Chain provider is a special provider that takes a list of providers and iterates over this list to get a timezone. Note that it **stops** its iteration when a provider returns a result.

```
$googleMaps = new Teazee\Provider\GoogleMaps($apiKey, $client, $messageFactory);
$timezoneDb = new Teazee\Provider\TimezoneDb($apiKey, $isPremium, $client, $messageFactory);
$teazee = new Teazee\Provider\Chain([$googleMaps, $timezoneDb]);
$zone = $teazee->find($lat, $lng);
```

### HTTP Clients

[](#http-clients)

In order to talk to time zone APIs, you need an HTTP client. Teazee relies on the [PSR-7 Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-7-http-message.md) and attempts to relieve you from worrying too much about its implementation.

You'll be required to include a package that provides an [php-http/client-implementation](https://packagist.org/providers/php-http/client-implementation), but the package you choose is up to you. If you want to let Teazee determine which HTTP classes to use, continue reading about Discovery.

#### Advanced: Discovery

[](#advanced-discovery)

To keep the number of dependencies on this package manageable, HTTP Discovery is not included by default.

If you'd like to use discovery, you'll need to require the `php-http/discovery` package:

```
composer require php-http/discovery

```

Discovery is based on [Puli](http://puli.io), which works best if you include its composer plugin, too:

```
composer require puli/composer-plugin

```

With discovery enabled, you can omit the `$client` and `$messageFactory` objects when creating your providers:

```
$provider = new Teazee\Provider\TimezoneDb($apiKey); // Client and MessageFactory will be created for you!
```

Extending Things
----------------

[](#extending-things)

You can write your own `provider` by implementing the `Provider` interface.

Versioning
----------

[](#versioning)

Teazee follows [Semantic Versioning](http://semver.org/).

Contributing
------------

[](#contributing)

See [`CONTRIBUTING`](https://github.com/wyndow/teazee/blob/master/CONTRIBUTING.md#contributing)file.

Unit Tests
----------

[](#unit-tests)

In order to run the test suite, install the development dependencies:

```
$ composer install --dev

```

Then, run the following command:

```
$ bin/kahlan

```

Credits
-------

[](#credits)

- Michael Crumm
- [All contributors](https://github.com/wyndow/teazee/contributors)

Special thanks goes to William Durand and the [Geocoder](https://github.com/geocoder-php/) project, upon which we based the application structure and documentation for Teazee.

Contributor Code of Conduct
---------------------------

[](#contributor-code-of-conduct)

As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.

We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.

Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.

Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.

This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at

License
-------

[](#license)

Teazee is released under the MIT License. See the bundled LICENSE file for details.

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 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.

###  Release Activity

Cadence

Every ~24 days

Total

5

Last Release

3731d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6ef52ce0a4d546c303cbf41b8003f68daed00f492bdb75e514cfba859df02621?d=identicon)[mcrumm](/maintainers/mcrumm)

---

Top Contributors

[![mcrumm](https://avatars.githubusercontent.com/u/168677?v=4)](https://github.com/mcrumm "mcrumm (68 commits)")

### Embed Badge

![Health badge](/badges/wyndow-teazee/health.svg)

```
[![Health](https://phpackages.com/badges/wyndow-teazee/health.svg)](https://phpackages.com/packages/wyndow-teazee)
```

###  Alternatives

[wallabag/wallabag

open source self hostable read-it-later web application

12.6k2.2k](/packages/wallabag-wallabag)[razorpay/ifsc

Razorpay IFSC Codes Library

382201.9k](/packages/razorpay-ifsc)[cheesegrits/filament-google-maps

A Google Maps package for Filament PHP with field, column and widget

322533.2k1](/packages/cheesegrits-filament-google-maps)[infusionsoft/php-sdk

PHP SDK for the Infusionsoft

1292.1M7](/packages/infusionsoft-php-sdk)[wi1dcard/baidu-mini-program-sdk

百度小程序第三方 PHP SDK，助力智能小程序开发。

544.0k1](/packages/wi1dcard-baidu-mini-program-sdk)[nexylan/nexycrypt

Let's Encrypt ACME protocol PHP client

1065.1k](/packages/nexylan-nexycrypt)

PHPackages © 2026

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