views:

907

answers:

3

I have a script that needs to display date data to an international audience - e.g.

"submitted Tue 25 Aug 09"

Is there an easier/cleaner way to get this converted to the French(etc) equivalent "Mar 25 Aoû 09" than:

Setting a constant LANG and a $LANGUAGES array of include files & :

if(LANG != 'EN')
{
include $LANGUAGES['LANG'];
}

& then the included file maps the days & months & replaces for the appropriate locale?

Thanks

David

+5  A: 

I think you can't get away from doing so without setting LOCALE:

<?php
setlocale(LC_ALL, 'fr_FR');

echo strftime("%A %e %B %Y");
?>

Some details on strftime: http://us2.php.net/manual/en/function.strftime.php

Jakub
This is the correct/PHP way of handling locale in date strings. `strftime()` is preferred over `date()` when you need to account for locale.
dcousineau
+1  A: 

According to the date function's manual page, you should use setlocale. Methods such as strftime will then use the locale specified. date, however, will not for some reason.

Samir Talwar
A: 

You might also want to have a look at Zend_Date.

André Hoffmann