3

Is there an easy way to retrieve the locale from the timezone_identifier?

For example:

date_default_timezone_set('Europe/Berlin');

The Locale in that case should de_DE.

SchmitzIT
  • 8,796
  • 9
  • 60
  • 87
casa
  • 33
  • 3
  • maybe better to use browser settings instead? http://stackoverflow.com/questions/297542/simplest-way-to-detect-client-locale-in-php – Serg Nov 02 '12 at 09:20

2 Answers2

2

As deceze said there is no possiblity of this. But you can get location information from timezone. as php.net says

$tz = new DateTimeZone("Europe/Prague"); 
print_r($tz->getLocation());
print_r(timezone_location_get($tz));

will output

Array
(
 [country_code] => CZ
 [latitude] => 50.08333
 [longitude] => 14.43333
 [comments] => 
)
Array
(
 [country_code] => CZ
 [latitude] => 50.08333
 [longitude] => 14.43333
 [comments] => 
)
Awais Qarni
  • 16,276
  • 23
  • 74
  • 134
1

No, because there's no such 1:1 correlation. Take Belgium for example, where they officially speak three languages in the same timezone.

deceze
  • 491,798
  • 79
  • 706
  • 853