PHP getlocale help, very easy points

Posted on 2009-05-26
Medium Priority
Last Modified: 2013-12-12
I've just been on www.php.net and this is still as clear as mud to me.

What I want to do is process code depending on the current user locale. I can't seem to find a function that does this.
If locale = "Europe/London" then
  do code 1
Else if locale = "USA"
  do code 2
Else if locale="Africa"
  do code 3

Question by:nicky2k
  • 3
LVL 14

Expert Comment

ID: 24471827

Use the server variable:


For testing:

LVL 14

Expert Comment

ID: 24471845

Author Comment

ID: 24471854
That just gets me the languages though, which could be used by any country. WhatI need is the timezone or country name itself.
LVL 14

Accepted Solution

shobinsun earned 200 total points
ID: 24472163

Use this:

$datetime = new DateTime();
echo $datetime->getTimezone()->getName() . "\n";

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

This article discusses how to create an extensible mechanism for linked drop downs.
The title says it all. Writing any type of PHP Application or API code that provides high throughput, while under a heavy load, seems to be an arcane art form (Black Magic). This article aims to provide some general guidelines for producing this typ…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

627 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question