{"id":13828275,"url":"https://github.com/spatie/google-time-zone","last_synced_at":"2025-05-15T23:04:08.317Z","repository":{"id":34774185,"uuid":"183008491","full_name":"spatie/google-time-zone","owner":"spatie","description":"Get time zones for coordinates","archived":false,"fork":false,"pushed_at":"2025-02-21T11:39:11.000Z","size":57,"stargazers_count":105,"open_issues_count":0,"forks_count":16,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-05-09T05:01:57.570Z","etag":null,"topics":["coordinates","geocoding","php","timezone"],"latest_commit_sha":null,"homepage":"https://spatie.be/open-source","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/spatie.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"custom":"https://spatie.be/open-source/support-us"}},"created_at":"2019-04-23T12:18:53.000Z","updated_at":"2025-04-04T04:40:47.000Z","dependencies_parsed_at":"2024-06-19T05:27:02.469Z","dependency_job_id":"e1ff27f8-fd83-4306-8d3a-e9f046091d16","html_url":"https://github.com/spatie/google-time-zone","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Fgoogle-time-zone","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Fgoogle-time-zone/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Fgoogle-time-zone/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Fgoogle-time-zone/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/spatie","download_url":"https://codeload.github.com/spatie/google-time-zone/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254436944,"owners_count":22070946,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["coordinates","geocoding","php","timezone"],"created_at":"2024-08-04T09:02:39.392Z","updated_at":"2025-05-15T23:04:08.277Z","avatar_url":"https://github.com/spatie.png","language":"PHP","funding_links":["https://spatie.be/open-source/support-us"],"categories":["PHP"],"sub_categories":[],"readme":"# Get the time zone used at the given coordinates\n\n[![Latest Version](https://img.shields.io/github/release/spatie/google-time-zone.svg?style=flat-square)](https://github.com/spatie/google-time-zone/releases)\n[![MIT Licensed](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)\n![run-tests](https://github.com/spatie/google-time-zone/workflows/run-tests/badge.svg)\n![Check \u0026 fix styling](https://github.com/spatie/google-time-zone/workflows/Check%20\u0026%20fix%20styling/badge.svg)\n[![Total Downloads](https://img.shields.io/packagist/dt/spatie/google-time-zone.svg?style=flat-square)](https://packagist.org/packages/spatie/google-time-zone)\n\nThis 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:\n\n```php\nGoogleTimeZone::getTimeZoneForCoordinates('51.2194475', '4.4024643');\n\n// Will return this array\n[\n    \"dstOffset\" =\u003e 0\n    \"rawOffset\" =\u003e 3600\n    \"timeZoneId\" =\u003e \"Europe/Brussels\"\n    \"timeZoneName\" =\u003e \"Central European Standard Time\"\n]\n```\n\n## Support us\n\n[\u003cimg src=\"https://github-ads.s3.eu-central-1.amazonaws.com/google-time-zone.jpg?t=1\" width=\"419px\" /\u003e](https://spatie.be/github-ad-click/google-time-zone)\n\nWe 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).\n\nWe 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).\n\n## Installation\n\nYou can install this package through composer.\n\n```bash\ncomposer require spatie/google-time-zone\n```\n## Laravel installation\n\nThough the package works fine in non-Laravel projects we've included some niceties for our fellow Artisans.\n\nIn Laravel will autoregister the package itself, but you should still publish the config file yourself.\n\n```bash\nphp artisan vendor:publish --provider=\"Spatie\\GoogleTimeZone\\GoogleTimeZoneServiceProvider\" --tag=\"config\"\n```\n\nThis is the content of the config file:\n\n```php\nreturn [\n    /*\n     * The api key used when sending timezone requests to Google.\n     */\n    'key' =\u003e env('GOOGLE_MAPS_TIMEZONE_API_KEY', ''),\n\n    /*\n     * The language param used to set response translations for textual data.\n     *\n     * More info: https://developers.google.com/maps/faq#languagesupport\n     */\n    'language' =\u003e '',\n];\n```\n\n## Usage\n\nHere's how you can get the time zone for a given set of coordinates.\n\n```php\n$googleTimeZone = new GoogleTimeZone();\n\n$googleTimeZone-\u003esetApiKey(config('google-time-zone.key'));\n\n$googleTimeZone-\u003egetTimeZoneForCoordinates('51.2194475', '4.4024643');\n\n/*\n// Will return this array\n[\n    \"dstOffset\" =\u003e 0\n    \"rawOffset\" =\u003e 3600\n    \"timeZoneId\" =\u003e \"Europe/Brussels\"\n    \"timeZoneName\" =\u003e \"Central European Standard Time\"\n]\n*/\n```\n\nYou can get the result back in a specific language.\n\n```php\n$googleTimeZone\n   -\u003esetLanguage('nl')\n   -\u003egetTimeZoneForCoordinates('51.2194475', '4.4024643');\n\n/*\n// Will return this array\n[\n      \"dstOffset\" =\u003e 0\n      \"rawOffset\" =\u003e 3600\n      \"timeZoneId\" =\u003e \"Europe/Brussels\"\n      \"timeZoneName\" =\u003e \"Midden-Europese standaardtijd\"\n]\n*/\n```\n\nIt 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.\n\n```php\n$googleTimeZone\n   -\u003esetTimestamp(new DateTime('13 august 2018'))\n   -\u003egetTimeZoneForCoordinates('51.2194475', '4.4024643');\n\n/*\n// Will return this array\n[\n      \"dstOffset\" =\u003e 3600\n      \"rawOffset\" =\u003e 3600\n      \"timeZoneId\" =\u003e \"Europe/Brussels\"\n      \"timeZoneName\" =\u003e \"Central European Summer Time\"\n]\n*/\n```\n\nIf you are using the package with Laravel, you can simply call `getTimeZoneForCoordinates`.\n\n```php\nGoogleTimeZone::getTimeZoneForCoordinates('51.2194475', '4.4024643');\n\n/*\n// Will return this array\n[\n    \"dstOffset\" =\u003e 0\n    \"rawOffset\" =\u003e 3600\n    \"timeZoneId\" =\u003e \"Europe/Brussels\"\n    \"timeZoneName\" =\u003e \"Central European Standard Time\"\n]\n*/\n```\n\nWhen no time zone was found `null` will be returned.\n\n## Postcardware\n\nYou'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.\n\nOur address is: Spatie, Kruikstraat 22, 2018 Antwerp, Belgium.\n\nWe publish all received postcards [on our company website](https://spatie.be/en/opensource/postcards).\n\n## Credits\n\n- [Ruben Van Assche](https://github.com/rubenvanassche)\n- [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspatie%2Fgoogle-time-zone","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspatie%2Fgoogle-time-zone","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspatie%2Fgoogle-time-zone/lists"}