All Projects → spatie → Google Time Zone

spatie / Google Time Zone

Licence: mit
Get time zones for coordinates

Projects that are alternatives of or similar to Google Time Zone

Googleapi
C# .NET Core Google Api (Maps, Places, Roads, Search, Translate). Supports all endpoints and requests / responses.
Stars: ✭ 346 (+540.74%)
Mutual labels:  timezone, geocoding
Geochile
Esta es una api de Geocodificación, para que, con las coordenadas Latitud y Longitud se entregue una lista de ciudades cercanas.
Stars: ✭ 13 (-75.93%)
Mutual labels:  geocoding
Dateutils
nifty command line date and time utilities; fast date calculations and conversion in the shell
Stars: ✭ 458 (+748.15%)
Mutual labels:  timezone
Use Places Autocomplete
😎 📍 React hook for Google Maps Places Autocomplete.
Stars: ✭ 739 (+1268.52%)
Mutual labels:  geocoding
Geocoderlaravel
Geocoder service provider for Laravel
Stars: ✭ 511 (+846.3%)
Mutual labels:  geocoding
Windows Iana
A small tool to convert Windows time zones to IANA
Stars: ✭ 17 (-68.52%)
Mutual labels:  timezone
Date Fns Tz
Complementary library for date-fns v2 adding IANA time zone support
Stars: ✭ 385 (+612.96%)
Mutual labels:  timezone
Tz offset
Simple abstraction of a timezone offset
Stars: ✭ 35 (-35.19%)
Mutual labels:  timezone
Time Zone Proposal
A proposal for accurately computing local time in JavaScript
Stars: ✭ 25 (-53.7%)
Mutual labels:  timezone
Geocoder
Complete Ruby geocoding solution.
Stars: ✭ 5,980 (+10974.07%)
Mutual labels:  geocoding
Leaflet Geosearch
(Leaflet) GeoSearch / GeoCode provider
Stars: ✭ 666 (+1133.33%)
Mutual labels:  geocoding
Valheim Docker
Valheim Docker powered by Odin. The Valheim dedicated gameserver manager which is designed with resiliency in mind by providing automatic updates, world backup support, and a user friendly cli interface.
Stars: ✭ 525 (+872.22%)
Mutual labels:  timezone
Paper Timezone
Polymer based timezone selection component
Stars: ✭ 19 (-64.81%)
Mutual labels:  timezone
Timezone Boundary Builder
A tool to extract data from Open Street Map (OSM) to build the boundaries of the world's timezones.
Stars: ✭ 469 (+768.52%)
Mutual labels:  timezone
Pelias Android Sdk
Android sdk for pelias
Stars: ✭ 20 (-62.96%)
Mutual labels:  geocoding
Geo Golang
Go library to access geocoding and reverse geocoding APIs
Stars: ✭ 394 (+629.63%)
Mutual labels:  geocoding
Geolocator
A utility for getting geo-location information via HTML5 and IP look-ups, geocoding, address look-ups, distance and durations, timezone information and more...
Stars: ✭ 598 (+1007.41%)
Mutual labels:  timezone
Swiftdate
🐔 Toolkit to parse, validate, manipulate, compare and display dates, time & timezones in Swift.
Stars: ✭ 6,661 (+12235.19%)
Mutual labels:  timezone
Nominatim Docker
Fully-featured container for geocoding, reverse geocoding and address lookup based on Nominatim and Open Street Map data.
Stars: ✭ 52 (-3.7%)
Mutual labels:  geocoding
Event Bot
📣 Discord Bot to make announcements about upcoming sessions for the Fellows using Google Calendar and Calendly
Stars: ✭ 21 (-61.11%)
Mutual labels:  timezone

Get the time zone used at the given coordinates

Latest Version MIT Licensed run-tests Check & fix styling Total Downloads

This package can convert GPS coordinates to time zones using Google's Time Zone service. 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

We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products.

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. We publish all received postcards on our virtual postcard wall.

Installation

You can install this package through composer.

composer require spatie/google-time-zone

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

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

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.

Credits

License

The MIT License (MIT). Please see License File for more information.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].