PHP code example of gsteel / google-timezone
1. Go to this page and download the library: Download gsteel/google-timezone 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/ */
gsteel / google-timezone example snippets
use DateTimeImmutable;
use GSteel\GoogleTimezone\Coordinates;
use GSteel\GoogleTimezone\HttpClient;
use Http\Client\Curl\Client;
use Laminas\Diactoros\RequestFactory;
use Laminas\Diactoros\UriFactory;
$apiKey = 'Some API Key';
$client = new HttpClient(
$apiKey,
new Client(),
new UriFactory(),
new RequestFactory()
);
$primeMeridian = '51.47,-0.00';
$referenceDate = DateTimeImmutable::createFromFormat('!Y-m-d', '2020-01-01');
$result = $this->client->fetch(
Coordinates::fromString($primeMeridian),
$referenceDate
);
assert($result->isSuccess()); // true
echo $result->timezone()->getName(); // "Europe/London"
$result->isReferenceDateDst(); // false
echo $result->name(); // "Greenwich Mean Time"
bash
composer