Jump to content

Archived

This topic is now archived and is closed to further replies.

e-man

current date in different languages

Recommended Posts

I use this snippet of php to put the current date on a HTML page:
[code]<?php
$today = date("F j, Y, g:i a");
echo $today;
?>  [/code]
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...

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
[!--quoteo(post=370361:date=May 1 2006, 09:31 PM:name=ober)--][div class=\'quotetop\']QUOTE(ober @ May 1 2006, 09:31 PM) [snapback]370361[/snapback][/div][div class=\'quotemain\'][!--quotec--]
From the manual:
[/quote]

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

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:
[code]<?php
$loc_de = setlocale(LC_ALL, 'de_DE@euro', 'de_DE', 'de', 'ge');
echo "Preferred locale for german on this system is '$loc_de'";
?>
[/code]

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

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.