the variable $_SERVER["HTTP_ACCEPT_LANGUAGE"] contains the Accept-Language- Header from the browser -> http://ch2.php.net/reserved.variables
with setlocale() you can set locale-informations -> http://ch2.php.net/function.setlocale
finally strftime() formats a date with the current locale-informations -> http://ch2.php.net/manual/en/function.strftime.php
sample script:
<?
if (preg_match("/^([a-z]{2}).([a-z]{2})$/i", $_SERVER["HTTP_ACCEPT_LANGUAGE"],
$m='')) { // e.g. de-ch
$locales[] = strtolower($m[1])."_".strtoupper($m[2]); // e.g. de_CH
$locales[] = strtolower($m[1]); // e.g. de
setlocale(LC_TIME, $locales);
} else if (preg_match("/^([a-z]{2})$/i", $_SERVER["HTTP_ACCEPT_LANGUAGE"],
$m='')) { // e.g. de
$locales[] = strtolower($m[1])."_".strtoupper($m[1]); // e.g. de_DE
$locales[] = strtolower($m[1]); // e.g. de
setlocale(LC_TIME, $locales);
}
echo strftime("%B", strtotime("+1 month"));
?>g. martin luethi
Mon, 26 Jan 2004 03:29:16 -0500 John Taylor-Johnston <[EMAIL PROTECTED]>:
Thanks!! :) Getting tired at this hour.
Is there a way to detect the language of the browser and echo the name of the month in that language?
<?= date("F", strtotime("+1 month")); ?>
Thanks, John
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

