PHP code example of myparcelcom / timezone-resolver
1. Go to this page and download the library: Download myparcelcom/timezone-resolver 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/ */
myparcelcom / timezone-resolver example snippets
use MyParcelCom\TimezoneResolver\TimezoneResolver;
$resolver = new TimezoneResolver(username: 'your-geonames-username');
$timezone = $resolver->getTimezone(
countryCode: 'NL',
postalCode: '1043NT',
city: 'Amsterdam',
);
// 'Europe/Amsterdam'
public function getTimezone(
string $countryCode,
?string $postalCode = null,
?string $city = null,
): ?string
use MyParcelCom\TimezoneResolver\TimezoneResolverInterface;
class MyService
{
public function __construct(
private readonly TimezoneResolverInterface $timezoneResolver,
) {}
}
use MyParcelCom\TimezoneResolver\TimezoneResolver;
use MyParcelCom\TimezoneResolver\TimezoneResolverInterface;
$this->app->singleton(
TimezoneResolverInterface::class,
fn () => new TimezoneResolver('my-geonames-username'),
);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.