PHPackages                             spatie/google-time-zone - 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. spatie/google-time-zone

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

spatie/google-time-zone
=======================

Get time zones for coordinates

1.3.0(2mo ago)110660.6k—5.2%171MITPHPPHP ^7.2|^8.0CI passing

Since Apr 26Pushed 2mo ago5 watchersCompare

[ Source](https://github.com/spatie/google-time-zone)[ Packagist](https://packagist.org/packages/spatie/google-time-zone)[ Docs](https://github.com/spatie/google-time-zone)[ Fund](https://spatie.be/open-source/support-us)[ RSS](/packages/spatie-google-time-zone/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (4)Versions (17)Used By (1)

Get the time zone used at the given coordinates
===============================================

[](#get-the-time-zone-used-at-the-given-coordinates)

[![Latest Version](https://camo.githubusercontent.com/572f7aaa823e275090e622d0d02bbfac4f69781aca869a75a4202cdf791a82e4/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f7370617469652f676f6f676c652d74696d652d7a6f6e652e7376673f7374796c653d666c61742d737175617265)](https://github.com/spatie/google-time-zone/releases)[![MIT Licensed](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![run-tests](https://github.com/spatie/google-time-zone/workflows/run-tests/badge.svg)](https://github.com/spatie/google-time-zone/workflows/run-tests/badge.svg)[![Check & fix styling](https://github.com/spatie/google-time-zone/workflows/Check%20&%20fix%20styling/badge.svg)](https://github.com/spatie/google-time-zone/workflows/Check%20&%20fix%20styling/badge.svg)[![Total Downloads](https://camo.githubusercontent.com/a598ec964f01d990ffda0f882a8ae48d0fc4c8ea7650911693ee622758dace69/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7370617469652f676f6f676c652d74696d652d7a6f6e652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/google-time-zone)

This package can convert GPS coordinates to time zones using [Google's Time Zone service](https://developers.google.com/maps/documentation/timezone/intro). Here's a quick example:

```
GoogleTimeZone::getTimeZoneForCoordinates('51.2194475', '4.4024643');

// Will return this array
[
    "dstOffset" => 0
    "rawOffset" => 3600
    "timeZoneId" => "Europe/Brussels"
    "timeZoneName" => "Central European Standard Time"
]
```

Support us
----------

[](#support-us)

[![](https://camo.githubusercontent.com/9c56f0e2a68c5c79135eb8ae5c96bd7125c49a5e94b0ca0176fbbb9b84614d62/68747470733a2f2f6769746875622d6164732e73332e65752d63656e7472616c2d312e616d617a6f6e6177732e636f6d2f676f6f676c652d74696d652d7a6f6e652e6a70673f743d31)](https://spatie.be/github-ad-click/google-time-zone)

We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).

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

[](#installation)

You can install this package through composer.

```
composer require spatie/google-time-zone
```

Laravel installation
--------------------

[](#laravel-installation)

Though the package works fine in non-Laravel projects we've included some niceties for our fellow Artisans.

In Laravel will autoregister the package itself, but you should still publish the config file yourself.

```
php artisan vendor:publish --provider="Spatie\GoogleTimeZone\GoogleTimeZoneServiceProvider" --tag="config"
```

This is the content of the config file:

```
return [
    /*
     * The api key used when sending timezone requests to Google.
     */
    'key' => env('GOOGLE_MAPS_TIMEZONE_API_KEY', ''),

    /*
     * The language param used to set response translations for textual data.
     *
     * More info: https://developers.google.com/maps/faq#languagesupport
     */
    'language' => '',
];
```

Usage
-----

[](#usage)

Here's how you can get the time zone for a given set of coordinates.

```
$googleTimeZone = new GoogleTimeZone();

$googleTimeZone->setApiKey(config('google-time-zone.key'));

$googleTimeZone->getTimeZoneForCoordinates('51.2194475', '4.4024643');

/*
// Will return this array
[
    "dstOffset" => 0
    "rawOffset" => 3600
    "timeZoneId" => "Europe/Brussels"
    "timeZoneName" => "Central European Standard Time"
]
*/
```

You can get the result back in a specific language.

```
$googleTimeZone
   ->setLanguage('nl')
   ->getTimeZoneForCoordinates('51.2194475', '4.4024643');

/*
// Will return this array
[
      "dstOffset" => 0
      "rawOffset" => 3600
      "timeZoneId" => "Europe/Brussels"
      "timeZoneName" => "Midden-Europese standaardtijd"
]
*/
```

It is possible to specify a timestamp for the location so that daylight savings can be taken into account. We will set this timestamp to the current time by default.

```
$googleTimeZone
   ->setTimestamp(new DateTime('13 august 2018'))
   ->getTimeZoneForCoordinates('51.2194475', '4.4024643');

/*
// Will return this array
[
      "dstOffset" => 3600
      "rawOffset" => 3600
      "timeZoneId" => "Europe/Brussels"
      "timeZoneName" => "Central European Summer Time"
]
*/
```

If you are using the package with Laravel, you can simply call `getTimeZoneForCoordinates`.

```
GoogleTimeZone::getTimeZoneForCoordinates('51.2194475', '4.4024643');

/*
// Will return this array
[
    "dstOffset" => 0
    "rawOffset" => 3600
    "timeZoneId" => "Europe/Brussels"
    "timeZoneName" => "Central European Standard Time"
]
*/
```

When no time zone was found `null` will be returned.

Postcardware
------------

[](#postcardware)

You're free to use this package, but if it makes it to your production environment we highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using.

Our address is: Spatie, Kruikstraat 22, 2018 Antwerp, Belgium.

We publish all received postcards [on our company website](https://spatie.be/en/opensource/postcards).

Credits
-------

[](#credits)

- [Ruben Van Assche](https://github.com/rubenvanassche)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

63

—

FairBetter than 99% of packages

Maintenance83

Actively maintained with recent releases

Popularity54

Moderate usage in the ecosystem

Community25

Small or concentrated contributor base

Maturity73

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~192 days

Recently: every ~279 days

Total

14

Last Release

84d ago

Major Versions

0.0.1 → 1.0.02019-05-17

PHP version history (4 changes)0.0.1PHP &gt;=7.2

1.0.0PHP ^7.3

1.0.1PHP ^7.2

1.2.2PHP ^7.2|^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/7535935?v=4)[Spatie](/maintainers/spatie)[@spatie](https://github.com/spatie)

---

Top Contributors

[![rubenvanassche](https://avatars.githubusercontent.com/u/619804?v=4)](https://github.com/rubenvanassche "rubenvanassche (29 commits)")[![freekmurze](https://avatars.githubusercontent.com/u/483853?v=4)](https://github.com/freekmurze "freekmurze (25 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (8 commits)")[![AdrianMrn](https://avatars.githubusercontent.com/u/12762044?v=4)](https://github.com/AdrianMrn "AdrianMrn (6 commits)")[![AlexVanderbist](https://avatars.githubusercontent.com/u/6287961?v=4)](https://github.com/AlexVanderbist "AlexVanderbist (3 commits)")[![AhmadWaleed](https://avatars.githubusercontent.com/u/23218299?v=4)](https://github.com/AhmadWaleed "AhmadWaleed (2 commits)")[![Ivanner](https://avatars.githubusercontent.com/u/4665453?v=4)](https://github.com/Ivanner "Ivanner (1 commits)")[![jdeveth](https://avatars.githubusercontent.com/u/10658879?v=4)](https://github.com/jdeveth "jdeveth (1 commits)")[![kevinpurwito](https://avatars.githubusercontent.com/u/11625012?v=4)](https://github.com/kevinpurwito "kevinpurwito (1 commits)")[![chapeupreto](https://avatars.githubusercontent.com/u/834048?v=4)](https://github.com/chapeupreto "chapeupreto (1 commits)")[![BackEndTea](https://avatars.githubusercontent.com/u/14289961?v=4)](https://github.com/BackEndTea "BackEndTea (1 commits)")

---

Tags

coordinatesgeocodingphptimezonelaravelmaplocationtime zonecoordinate

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/spatie-google-time-zone/health.svg)

```
[![Health](https://phpackages.com/badges/spatie-google-time-zone/health.svg)](https://phpackages.com/packages/spatie-google-time-zone)
```

###  Alternatives

[spatie/geocoder

Geocoding addresses to coordinates

8404.8M15](/packages/spatie-geocoder)[stevebauman/location

Retrieve a user's location by their IP Address

1.3k7.6M65](/packages/stevebauman-location)[nativephp/mobile

NativePHP for Mobile

82724.0k43](/packages/nativephp-mobile)[bensampo/laravel-embed

Painless responsive embeds for videos, slideshows and more.

142146.8k](/packages/bensampo-laravel-embed)[glhd/conveyor-belt

14797.0k](/packages/glhd-conveyor-belt)[adrianorosa/laravel-geolocation

Laravel Geo Location package to get details for a given IP Address

6593.3k1](/packages/adrianorosa-laravel-geolocation)

PHPackages © 2026

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