Friday, 14 November 2014

Current time zone for a city- Free API

Current time zone for a city- Free API

Get TimeZone & Local time from Latitude/Longitude



$localtime = 0;
$latitude = '40.71417';
$longitude = '-74.00639';
try {
    $client = new Zend_Http_Client('http://www.earthtools.org/timezone-1.1/' . $latitude . '/' . $longitude);
    $response = $client->request('GET');
    $xmlData = $response->getBody();
    if (!empty($xmlData)) {
        $xmlData = simplexml_load_string($xmlData);  
        print_r($xmlData);
    }

} catch (Exception $e) {
    echo 'Error' . $e->getMessage();
}

Output:

SimpleXMLElement Object
(
    [version] => 1.0
    [location] => SimpleXMLElement Object
        (
            [latitude] => 40.71417
            [longitude] => -74.00639
        )
    [offset] => -5
    [suffix] => R
    [localtime] => 13 Nov 2014 01:42:07
    [isotime] => 2014-11-13 01:42:07 -0500
    [utctime] => 2014-11-13 06:42:07
    [dst] => Unknown
)


Get Latitude/Longitude from address


http://maps.googleapis.com/maps/api/geocode/json?address=chandigarh&sensor=false

Output:
http://maps.googleapis.com/maps/api/geocode/json?address=chandigarh&sensor=false



Friday, 7 November 2014

Enabling the openssl in Wamp-Xampp

Enabling the openssl in Wamp-Xampp

If you have any of following issue, then you are on right page.

  • How to enable SSL
  • Enabling the openssl in WampServer/xampp
  • How to enable openssl support in XAMPP
  • Unable to Connect to ssl
  • Fatal error: Uncaught exception Zend_Http_Client_Adapter_Exception


Solution: enable the extension php_openssl from PHP Extension

Option 1 (If using Wamp-Server)

Enabling the openssl in Wamp










and Restart your wamp Server


Option 2 (Direct change in php.ini File)
You can do direct change
Just comment your php_openssl.dll in your php.ini file.
Search
;extension=php_openssl.dll
Replace with
extension=php_openssl.dll
Here we have just removed the semicolon.