jvit
JVIT PHPThis code will get the time zone from a request from an IP address.
Shortcut: date.timezone
/**
* Get time zone by request ip
*
*/
function getTimeZoneUser()
{
$json = file_get_contents('http://ip-api.com/json');
$timezone = '';
if (!empty($json)) {
$ipData = json_decode($json, true);
if (!empty($ipData['timezone'])) {
$timezone = $ipData['timezone'];
}
}
return $timezone;
}