PHP code example of tochka-developers / geo-timezone

1. Go to this page and download the library: Download tochka-developers/geo-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/ */

    

tochka-developers / geo-timezone example snippets


use Tochka\GeoTimeZone\UpdaterData;
use Tochka\GeoTimeZone\Indexer;

$updater = new UpdaterData('/path/to/base/data/');
$dataPath = $updater->updateData();

$dataRepository = new JsonFileDataRepository($dataPath, '/path/to/index/data/directory');
$indexer = new Indexer($dataRepository);
$indexer->index();

    use Tochka\GeoTimeZone\TimezoneFinder;
    use Tochka\GeoTimeZone\DataRepository\JsonFileDataRepository;

    $latitude = 39.452800;
    $longitude = -0.347038;
    $timestamp = 1469387760;

    $dataRepository = new JsonFileDataRepository('/path/to/base/data/file.json', '/path/to/index/data/');
    $timezoneFinder = new TimezoneFinder($dataRepository);

    // TimeZone name
    $timeZoneName = $timezoneFinder->findTimezone($latitude, $longitude);
    //Europe/Madrid