Jump to content

current date in different languages


e-man

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...
Link to comment
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]
Link to comment
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?
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.