e-man Posted May 1, 2006 Share Posted May 1, 2006 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 https://forums.phpfreaks.com/topic/8830-current-date-in-different-languages/ Share on other sites More sharing options...
ober Posted May 1, 2006 Share Posted May 1, 2006 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 https://forums.phpfreaks.com/topic/8830-current-date-in-different-languages/#findComment-32427 Share on other sites More sharing options...
e-man Posted May 1, 2006 Author Share Posted May 1, 2006 [!--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]<?phpsetlocale(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 https://forums.phpfreaks.com/topic/8830-current-date-in-different-languages/#findComment-32490 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.