<?php
$ip = $_SERVER['REMOTE_ADDR'];

$request_url = "http://ipinfo.io/".$ip."/loc";
$data = file_get_contents($request_url); 
$split = explode(",",  $data);
$lat = $split[0];
$lon = trim($split[1]);

$request_url = "https://maps.googleapis.com/maps/api/timezone/json?location=".$lat.",".$lon."&timestamp=1331161200";
$json = file_get_contents($request_url);
$data = json_decode($json);


$dateTimeZoneRemote = new DateTimeZone($data->timeZoneId);
$timeRemote = new DateTime('now', $dateTimeZoneRemote);
$datTimeZoneUtc = new DateTimeZone('UTC');
$timelocal = new DateTime('now', $datTimeZoneUtc);

$offset = $dateTimeZoneRemote->getOffset( $timelocal ) / 3600;
echo $offset;

?>
