View Full Version : display date in German - php date strftime
crmpicco
09-30-2007, 06:49 PM
<?php
date_default_timezone_set('Europe/Berlin');
// Set the gloabal LC_TIME constant to german
setlocale(LC_TIME, 'de_DE');
// Little bit other Syntax but better effect
echo "time " . strftime('%A, %d. %B %Y') . "<br>"; //Output: Mittwoch, 07. September 2005
?>
I am attempting to display the date in German with the code above. Can anyone tell me how it is done as it is still showing in English.
Cheers, Picco
Mwnciau
09-30-2007, 07:12 PM
if($lc = setlocale(LC_ALL, "de_DE", "de_DE@euro", "deu", "deu_deu", "german"))
echo "<p>Locale setting is \"$lc\".</p>";
else
echo "<p>Couldn't change to a German locale.</p>";
crmpicco
09-30-2007, 07:40 PM
cheers mate, that writes out:
Locale setting is "German_Germany.1252".
So how can I change "Sunday 30th September" to "Sonntag 30....."???
Picco
Mwnciau
09-30-2007, 07:48 PM
<?php
date_default_timezone_set('Europe/Berlin');
// Set the gloabal LC_TIME constant to german
setlocale(LC_ALL, "de_DE", "de_DE@euro", "deu", "deu_deu", "german")
// Little bit other Syntax but better effect
echo "time " . strftime('%A, %d. %B %Y') . "<br>"; //Output: Mittwoch, 07. September 2005
?>
crmpicco
09-30-2007, 07:53 PM
excellent, worked perfect!! I take it I can set the locale back to en_EN for the English part of my site?
crmpicco
09-30-2007, 07:54 PM
repuation boost and a "thank" :-) cheer again bud!!!
Picco
Mwnciau
09-30-2007, 08:00 PM
excellent, worked perfect!! I take it I can set the locale back to en_EN for the English part of my site?
If not en_EN then one of the ones found on MSDN (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_crt_language_strings.asp).
PHPycho
02-04-2008, 11:05 AM
sorry that doesnt work for php4. it says date_default_timezone_set() doesnt exists. whats the alternative solution for this.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.