Loading ...
Sorry, an error occurred while loading the content.

city to timezone?

Expand Messages
  • munim2020
    Hi.. I need a good way to get the timezone information for any city. For any city in the world, I should be able to get the timezone offset and daylight
    Message 1 of 10 , May 17, 2010
    • 0 Attachment
      Hi..
      I need a good way to get the timezone information for any city. For any city
      in the world, I should be able to get the timezone offset and daylight
      savings data if any. Is there any API to get this done?

      --
      Abdul Munim Kazia
      mail@...


      [Non-text portions of this message have been removed]
    • peterkr
      You will get timezone and locations by IP Address from : http://ipinfodb.com/ip_location_api.php Thanks Peter
      Message 2 of 10 , May 27, 2010
      • 0 Attachment
        You will get timezone and locations by IP Address from :

        http://ipinfodb.com/ip_location_api.php

        Thanks
        Peter

        --- In bang-phpug@yahoogroups.com, munim2020 <munim2020@...> wrote:
        >
        > Hi..
        > I need a good way to get the timezone information for any city. For any city
        > in the world, I should be able to get the timezone offset and daylight
        > savings data if any. Is there any API to get this done?
        >
        > --
        > Abdul Munim Kazia
        > mail@...
        >
        >
        > [Non-text portions of this message have been removed]
        >
      • munim2020
        IP address? My query has nothing to with IP addresses. Anyway, I have wrote my own solution to this problem. If anyone needs it, I can post it here. ... --
        Message 3 of 10 , May 27, 2010
        • 0 Attachment
          IP address? My query has nothing to with IP addresses.
          Anyway, I have wrote my own solution to this problem. If anyone needs it, I
          can post it here.

          On 27 May 2010 15:40, peterkr <peterkr2003@...> wrote:

          >
          >
          > You will get timezone and locations by IP Address from :
          >
          > http://ipinfodb.com/ip_location_api.php
          >
          > Thanks
          > Peter
          >
          >
          > --- In bang-phpug@yahoogroups.com <bang-phpug%40yahoogroups.com>,
          > munim2020 <munim2020@...> wrote:
          > >
          > > Hi..
          > > I need a good way to get the timezone information for any city. For any
          > city
          > > in the world, I should be able to get the timezone offset and daylight
          > > savings data if any. Is there any API to get this done?
          > >
          > > --
          > > Abdul Munim Kazia
          > > mail@...
          > >
          > >
          > > [Non-text portions of this message have been removed]
          > >
          >
          >
          >



          --
          Abdul Munim Kazia
          mail@...


          [Non-text portions of this message have been removed]
        • Harsha M V
          plz post it here. -- Harsha M V http://harshamv.com/ http://variable3.com/ [Non-text portions of this message have been removed]
          Message 4 of 10 , May 27, 2010
          • 0 Attachment
            plz post it here.


            --
            Harsha M V

            http://harshamv.com/
            http://variable3.com/


            [Non-text portions of this message have been removed]
          • munim2020
            Note: This makes calls to 2 different web services. So if your application needs to do this very often on a regular basis, its advised to store results in a
            Message 5 of 10 , May 27, 2010
            • 0 Attachment
              Note:
              This makes calls to 2 different web services. So if your application needs
              to do this very often on a regular basis, its advised to store results in a
              database.

              function gettimezone($address)
              {
              $_url = 'http://api.local.yahoo.com/MapsService/V1/geocode';
              $_url .=
              sprintf('?appid=%s&location=%s',"phpclasses",rawurlencode($address));
              $_result = false;
              if($_result = file_get_contents($_url)) {

              preg_match('!<Latitude>(.*)</Latitude><Longitude>(.*)</Longitude>!U',
              $_result, $_match);
              $lng = $_match[2];
              $lat = $_match[1];
              $url = "http://ws.geonames.org/timezone?lat={$lat}&lng={$lng}";
              $timedata = file_get_contents($url);
              $sxml = simplexml_load_string($timedata);
              return $sxml->timezone;
              }
              else
              return false;
              }

              --
              Abdul Munim Kazia
              mail@...


              [Non-text portions of this message have been removed]
            • Harsha M V
              *Warning*: file_get_contents( http://api.local.yahoo.com/MapsService/V1/geocode?appid=phpclasses&location=[ip-removed]) [function.file-get-contents
              Message 6 of 10 , May 28, 2010
              • 0 Attachment
                *Warning*: file_get_contents(
                http://api.local.yahoo.com/MapsService/V1/geocode?appid=phpclasses&location=[ip-removed])
                [function.file-get-contents <http://localhost/function.file-get-contents>]:
                failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request in *
                C:\wamp\www\test.php* on line *34*


                am getting that error


                --
                Harsha M V

                http://harshamv.com/
                http://variable3.com/


                [Non-text portions of this message have been removed]
              • munim2020
                Sample request: http://api.local.yahoo.com/MapsService/V1/geocode?appid=phpclasses&location=bangalore
                Message 7 of 10 , May 28, 2010
                • 0 Attachment
                  Sample request:
                  http://api.local.yahoo.com/MapsService/V1/geocode?appid=phpclasses&location=bangalore
                  <http://api.local.yahoo.com/MapsService/V1/geocode?appid=phpclasses&location=bangalore>Works
                  for me.
                  Just make check if there is any safety feature enabled in your php
                  installation which disallows file-get-contents to fetch external data. I
                  think there is a such a setting in php.ini but I don't remember exactly.

                  By the way, the location attribute is a physical address like a city or a
                  state, not an ip address.

                  On 28 May 2010 13:02, Harsha M V <hmvrulz@...> wrote:

                  >
                  >
                  > *Warning*: file_get_contents(
                  >
                  > http://api.local.yahoo.com/MapsService/V1/geocode?appid=phpclasses&location=
                  > [ip-removed])
                  > [function.file-get-contents <http://localhost/function.file-get-contents
                  > >]:
                  > failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request in *
                  > C:\wamp\www\test.php* on line *34*
                  >
                  > am getting that error
                  >
                  >
                  > --
                  > Harsha M V
                  >
                  > http://harshamv.com/
                  > http://variable3.com/
                  >
                  > [Non-text portions of this message have been removed]
                  >
                  >
                  >



                  --
                  Abdul Munim Kazia
                  mail@...


                  [Non-text portions of this message have been removed]
                • Harsha M V
                  oops i was using ip address.. is there a ip to city service ? -- Harsha M V http://harshamv.com/ http://variable3.com/ [Non-text portions of this message have
                  Message 8 of 10 , May 28, 2010
                  • 0 Attachment
                    oops i was using ip address..

                    is there a ip to city service ?
                    --
                    Harsha M V

                    http://harshamv.com/
                    http://variable3.com/


                    [Non-text portions of this message have been removed]
                  • munim2020
                    Oh.. that has nothing to do with this discussion. My code is for getting the timezone information of any city. But yeah, you can easily find what you want by
                    Message 9 of 10 , May 28, 2010
                    • 0 Attachment
                      Oh.. that has nothing to do with this discussion. My code is for getting the
                      timezone information of any city. But yeah, you can easily find what you
                      want by googling "ip geolocation".

                      On 28 May 2010 15:10, Harsha M V <hmvrulz@...> wrote:

                      >
                      >
                      > oops i was using ip address..
                      >
                      > is there a ip to city service ?
                      >
                      > --
                      > Harsha M V
                      >
                      > http://harshamv.com/
                      > http://variable3.com/
                      >
                      > [Non-text portions of this message have been removed]
                      >
                      >
                      >



                      --
                      Abdul Munim Kazia
                      mail@...


                      [Non-text portions of this message have been removed]
                    • Harsha M V
                      i know.. i just wanted to knw how this was done... may be of use some day.. thanks for the script.. nice one. -- Harsha M V http://harshamv.com/
                      Message 10 of 10 , May 28, 2010
                      • 0 Attachment
                        i know.. i just wanted to knw how this was done... may be of use some day..
                        thanks for the script.. nice one.


                        --
                        Harsha M V

                        http://harshamv.com/
                        http://variable3.com/


                        [Non-text portions of this message have been removed]
                      Your message has been successfully submitted and would be delivered to recipients shortly.