By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,203 Members | 1,358 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,203 IT Pros & Developers. It's quick & easy.

[Windows + PHP5] Localizing date()?

P: n/a
Hello

I'm trying to localize a small PHP application which uses
date() to display a date saved as Epoch in MySQL, but I can't get the
month to be displayed in French:

=========
//BAD setlocale(LC_ALL, 'fr_FR@euro', 'fr_FR', 'fra_fra');
//BAD setlocale(LC_ALL, 'fra_fra');
//BAD setlocale(LC_ALL, 'french');
//BAD setlocale(LC_ALL, 'fr_FR');
//BAD setlocale(LC_ALL, 'fr-FR');
//BAD setlocale(LC_ALL, 'fr');
//BAD too
setlocale(LC_ALL, 'French');

//27 December 2007 instead of
//27 décembre 2007
echo date('d F Y', '1198790064');
=========

I read the comments in www.php.net/date , and was wondering...

1. Why PHP5 seems to have a problem with locales, and

2. What would be the least complicated way to change this call to
date()?

Thank you.
Dec 28 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On Fri, 28 Dec 2007 04:10:57 +0100, Gilles Ganault <no****@nospam.com>
wrote:
>2. What would be the least complicated way to change this call to
date()?
For those interested, it seems like date() always displays date/time
using the US locale, while strftime() uses the selected locale.

For instance, the following does display the date according to the
French locale:

===========
setlocale(LC_ALL, 'French');

//27 December 2007
echo date('d F Y', '1198790064') . "<p>";

//27 décembre 2007
echo strftime('%d %B %Y', '1198790064');
===========

HTH,
Dec 28 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.