1. Go to this page and download the library: Download spatie/google-time-zone library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
spatie / google-time-zone example snippets
GoogleTimeZone::getTimeZoneForCoordinates('51.2194475', '4.4024643');
// Will return this array
[
"dstOffset" => 0
"rawOffset" => 3600
"timeZoneId" => "Europe/Brussels"
"timeZoneName" => "Central European Standard Time"
]
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' => '',
];
$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"
]
*/