src/Panda/Localization/GeoIp.php
public function getTimezoneByIP($ipAddress = '')
    {
        // Get remote ip address if empty
        $ipAddress = (empty($ipAddress) ? $this->request->server->get('REMOTE_ADDR') : $ipAddress);

        // Get country code
        // In the future should be replaced with full region info
        // to support countries with more than 1 timezones
        $countryCode = $this->getCountryCode2ByIP($ipAddress);

        // Check implementation
        if (!function_exists('geoip_time_zone_by_country_and_region')) {
            throw new Exception('geoip_time_zone_by_country_and_region() function is not available.');
        }

        // Return timezone
        return geoip_time_zone_by_country_and_region($countryCode);
    }
public function getTimezoneByIP($ipAddress = '')
    {
        // Get remote ip address if empty
        $ipAddress = (empty($ipAddress) ? $this->request->server->get('REMOTE_ADDR') : $ipAddress);

        // Get country code
        // In the future should be replaced with full region info
        // to support countries with more than 1 timezones
        $countryCode = $this->getCountryCode2ByIP($ipAddress);

        // Check implementation
        if (!function_exists('geoip_time_zone_by_country_and_region')) {
            throw new Exception('geoip_time_zone_by_country_and_region() function is not available.');
        }

        // Return timezone
        return geoip_time_zone_by_country_and_region($countryCode);
    }
public function getTimezoneByIP ( $ ipAddress = '' ) { // Get remote ip address if empty $ ipAddress = ( empty ( $ ipAddress ) ? $ this -> request -> server -> get ( 'REMOTE_ADDR' ) : $ ipAddress ) ; // Get country code // In the future should be replaced with full region info // to support countries with more than 1 timezones $ countryCode = $ this -> getCountryCode2ByIP ( $ ipAddress ) ; // Check implementation if ( ! function_exists ( 'geoip_time_zone_by_country_and_region' ) ) { throw new Exception ( 'geoip_time_zone_by_country_and_region() function is not available.' ) ; } // Return timezone return geoip_time_zone_by_country_and_region ( $ countryCode ) ; }
Get the corresponding timezone according to ip address.

@param string $ipAddress The ip address to get the timezone for.

@return string

@throws Exception
Get the corresponding timezone according to ip address .