Table of Contents

Syntax

string setlocale( string $category, string $locale [, string $... )

(PHP 4, PHP 5)

$category The category of locale information to set.
$locale If NULL or empty string, the locale names modified will be set based upon environment variables. If $locale is “0”, no settings are affected and instead the current setting is returned. If you pass an array for the $locale, the system will attempt to set each value from the array and the list of parameters which follows it.
RETURNS The current setting for the locale if $locale is set to “0”.

What it Does

This method will set locale information for various PHP functions which are locale-specific. An example of these functions are strcoll, strftime, and localeconv.

Category

LC_ALL Indicates modifications affect all categories (listed below)
LC_COLLATE Localed settings only affect string collations.
LC_CTYPE Only character class methods and conversions are affected.
LC_MONETARY Only monetary functions are affected.
LC_NUMERIC Only decimal separator functions are affected.
LC_TIME Only date and time functions are affected.
LC_MESSAGES Only system responses are affected.

Example

// Set the locale to English (Great Britain) and format a date
setlocale(LC_ALL, 'en_GB');
echo 'Current Time: ' . strftime('%M j, Y h:ia', time()) . '<br>';