Jump to content


Photo

current date in different languages


  • Please log in to reply
2 replies to this topic

#1 e-man

e-man
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 01 May 2006 - 06:54 PM

I use this snippet of php to put the current date on a HTML page:
<?php 
$today = date("F j, Y, g:i a");
echo $today;
?>  
which gives me March 10, 2001, 5:16 pm (in English)
Is there any way of doing this in Spanish and German as well, I mean have the name of the month appear in Spanish or German?
Any help welcome!

PS the server this runs on only has php 4.1 if this helps...

#2 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 01 May 2006 - 07:31 PM

From the manual:
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]To format dates in other languages, you should use the setlocale() and strftime() functions instead of date(). [/quote]

Info: PHP Manual


#3 e-man

e-man
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 01 May 2006 - 11:58 PM

[!--quoteo(post=370361:date=May 1 2006, 09:31 PM:name=ober)--][div class=\'quotetop\']QUOTE(ober @ May 1 2006, 09:31 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
From the manual:
[/quote]

Thanks, I searched the php docs for those functions and tried this snippet:
<?php
setlocale(LC_ALL, 'es_ES@euro');
echo strftime("%A %d %B %Y");
?>

On my own server (php 4.3.1) it works as it should (i.e. I get the date in Spanish martes 02 mayo 2006), on the test server (php 4.1) nothing happens.
Even running this snippet:
<?php
$loc_de = setlocale(LC_ALL, 'de_DE@euro', 'de_DE', 'de', 'ge');
echo "Preferred locale for german on this system is '$loc_de'";
?>

on the test server gives nothing. I'm assuming I need at least 4.3, anyone know if this is a known issue?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users