Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP date() in foreign languages - e.g. Mar 25 Aoû 09 [duplicate]

Tags:

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?

like image 476
David Miller Avatar asked Aug 25 '09 12:08

David Miller


2 Answers

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

like image 73
Jakub Avatar answered Sep 29 '22 14:09

Jakub


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.

like image 31
Samir Talwar Avatar answered Sep 29 '22 13:09

Samir Talwar