Re: Detect language date(F)

From: Date: Mon, 26 Jan 2004 19:36:04 +0000
Subject: Re: Detect language date(F)
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-175799@lists.php.net to get a copy of this message
I see what you are doing, But don't see where to create fr or fr-ca, for my example? John Martin Luethi wrote: > 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 > <taylorjo@collegesherbrooke.qc.ca>: > > > 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")); ?>

« previous php.general (#175799) next »