I want to set the timezone to the visitor's timezone.
I am doing it like this way:
$ip = $_REQUEST['REMOTE_ADDR']; // the IP address to query
$query = @unserialize(file_get_contents('http://ip-api.com/php/'.$ip));
if($query && $query['status'] == 'success') {
date_default_timezone_set($query['timezone']);
} else {
echo 'Unable to get location';
}
However, when another visitor visits the site he will have the timezone of the previous visitor ...
Why doesn't date_default_timezone
clears? Is there's any solution to that?
Any help would be appreciated.
Thanks!