Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/aaronpk/p3k-timezone
Look up the timezone given a latitude and longitude
https://github.com/aaronpk/p3k-timezone
indieweb p3k timezone
Last synced: 19 days ago
JSON representation
Look up the timezone given a latitude and longitude
- Host: GitHub
- URL: https://github.com/aaronpk/p3k-timezone
- Owner: aaronpk
- License: apache-2.0
- Created: 2017-01-12T17:32:04.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-01-12T18:18:01.000Z (almost 8 years ago)
- Last Synced: 2024-10-04T01:05:51.294Z (about 1 month ago)
- Topics: indieweb, p3k, timezone
- Language: PHP
- Homepage: https://p3k.io
- Size: 188 KB
- Stars: 4
- Watchers: 4
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
Timezone
========This library provides a function for retrieving the timezone for a given location.
It is implemented as a single file with no external dependencies. To do this, a horrible cheat is used. The timezone for a location is found by looking up the timezone of the nearest city. This means it's possible that the wrong timezone will be returned for locations near the borders between timezones, so you should only use this library if that is an acceptable compromise. The tradeoff is no fancy geometry or databases are required so this is comparatively fast.
API
---```php
$timezone = p3k\Timezone::timezone_for_location($latitude, $longitude);
```Returns a string with the timezone name such as "Europe/Berlin", which can be used to create a new `DateTimeZone` object.