How to get Locale using Php,I want to get the time zone based on the location, is there any possibility to get in php.
I need to convert it to GMT and save Database.Again i need to Pull it back to UI with same time same time zone.
Using
setlocale (LC_ALL,"0");
to get in the result the actual locale.
LC_CTYPE=de_DE.UTF8;LC_NUMERIC=C;LC_TIME=de_DE.UTF8;LC_COLLATE=de_DE.UTF8;LC_MONETARY=de_DE.UTF8;LC_MESSAGES=C;LC_PAPER=C;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=C;LC_IDENTIFICATION=C and sometimes just C. Strange bug.C is the default setting, if no locale was ever set before. It means nothing. Try money_format('%i', 123.45); while you got this C. There will be no currency => 123.45. But set it to en_EN and you will get USD 123.45. You can also set a local and after it set it back to the state before with following call setlocale(LC_ALL, 'C')... See also here: unix.stackexchange.com/questions/87745/what-does-lc-all-c-doYou can't get the client's locale or timezone from the server side, and you can only make a guess at it from the client side, using JavaScript.
(You can get more locale information if the browser supports Java, but that's a bit of a pain and everyone hates applets.)
To handle timezones in a web application, store all your times as UTC timestamps, and convert them to text for on-page formatting using a user-chosen timezone. You can use methods like in this question to guess at the timezone, but since this is not reliable you should also allow the user to explicitly choose timezone.
timezone_identifier they are using manually, to pass to date_default_timezone_set as described by Sarfraz. See php.net/manual/en/timezones.php for the list of identifiers; you could put them in a drop-down box or other UI. You can use JavaScript to pick a best-guess timezone for the default value of the drop-down, as in the question I linked, or simply default to UTC. Once the user has input a time and timezone, you should convert it to UTC for database storage.You can use:
date_default_timezone_set('Europe/London');
date_default_timezone_get; // Europe/London
or
if (ini_get('date.timezone')) {
echo 'date.timezone: ' . ini_get('date.timezone');
}
locale!=locationI beleive you meanlocation,localeis a setting for country and language of a system