简体   繁体   中英

How to get country name from time of android mobile?

Hi I am very new to Android Development. I want to pick the country name based on the current time of the particular mobile, while clicking the button. How can i do it? Any body tell me? Thanks in advance.

Per above, the closest you'll get comes from here :

For getting the time zone, check out the "O" and "T" format specifiers of the date() function. "O" will give you the Difference to Greenwich time (GMT) in hours (your time zone offset) and "T" will give you the time zone abbreviation like "EST" for Eastern Standard Time.

eg <?php echo date("T"); ?> <?php echo date("T"); ?> will give you the executing PHP script timezone, for the user timezome you can pass their date/time as the second argument.

It seems difficult considering most timezones contain multiple countries (and countries multiple timezones as well).

See: Android: Is there a way to get timezone for Country name?

I don't think thats possible because you can have MANY MANY countries on the same time. For example, just take the GMT+/-0 time zone, you'll have England, France, Spain, Portugal, and a few others you can get from the african countries. You can't do it like that.

What i'd suggest is to implement a GEOIP location using for example: MaxMind GEOIP. You have some very powerful tools available in PEAR for that and it took me about 4 hours to setup the library, understand the code and do the code to query. I was querying for IPs and countries and even states/provinces in less than 4 hours. You can't get faster than that unless your a genious :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM