PHP code example of charlesportwoodii / geo-timezone
1. Go to this page and download the library: Download charlesportwoodii/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/ */
charlesportwoodii / geo-timezone example snippets
use GeoTimeZone\UpdaterData;
$updater = new UpdaterData("/path/to/data/");
$updater->updateData();
use GeoTimeZone\Calculator;
$latitude = 39.452800;
$longitude = -0.347038;
$timestamp = 1469387760;
$calculator = new Calculator("/path/to/data/");
// Local date
$localDate = $calculator->getLocalDate($latitude, $longitude, $timestamp);
/* DateTime Object
(
[date] => 2016-07-24 21:16:00.000000
[timezone_type] => 3
[timezone] => Europe/Madrid
)
*/
// TimeZone name
$timeZoneName = $calculator->getTimeZoneName($latitude, $longitude);
//Europe/Madrid