It's not straight forward but I get the time including daylight saving offset from 2 api calls using jquery and php. All of it could be done in PHP quite easily with a bit of adaptation.
I'm sure this could be laid out differently too but I just grabbed it from existing code which suited my needs at the time.
Jquery/php:
function get_user_time(){
var server_time = <? echo time(); ?>; //accuracy is not important it's just to let google know the time of year for daylight savings time
$.ajax({
url: "locate.php",
dataType: "json",
success: function(user_location) {
if(user_location.statusCode=="OK"){
$.ajax({
url: "https://maps.googleapis.com/maps/api/timezone/json?location="+user_location.latitude+","+user_location.longitude+"×tamp="+server_time+"&sensor=false",
dataType: "json",
success: function(user_time) {
if(user_time.statusCode=="error"){
//handle error
}else{
user_time.rawOffset /= 3600;
user_time.dstOffset /= 3600;
user_real_offset = user_time.rawOffset+user_time.dstOffset+user_time.utc;
//do something with user_real_offset
}
}
});
}
}
});
}
locate.php
function get_client_ip() {
$ipaddress = '';
if ($_SERVER['HTTP_CLIENT_IP'])
$ipaddress = $_SERVER['HTTP_CLIENT_IP'];
else if($_SERVER['HTTP_X_FORWARDED_FOR'])
$ipaddress = $_SERVER['HTTP_X_FORWARDED_FOR'];
else if($_SERVER['HTTP_X_FORWARDED'])
$ipaddress = $_SERVER['HTTP_X_FORWARDED'];
else if($_SERVER['HTTP_FORWARDED_FOR'])
$ipaddress = $_SERVER['HTTP_FORWARDED_FOR'];
else if($_SERVER['HTTP_FORWARDED'])
$ipaddress = $_SERVER['HTTP_FORWARDED'];
else if($_SERVER['REMOTE_ADDR'])
$ipaddress = $_SERVER['REMOTE_ADDR'];
else
$ipaddress = 'UNKNOWN';
return $ipaddress;
}
$location = file_get_contents('http://api.ipinfodb.com/v3/ip-city/?key=xxxxxxxxx&ip='.get_client_ip().'&format=json');
$location = json_decode($location,true);
if(is_array($location)){
date_default_timezone_set('UTC');
$location['utc'] = time();
echo json_encode($location);
}else{
echo '{"statusCode":"error"}';
}
Register for a free key here: http://ipinfodb.com/register.php (no limits but queued if more than 1 request per second)