Translate date("d F Y (H:i) function php Translate date("d F Y (H:i) function php wordpress wordpress

Translate date("d F Y (H:i) function php


WordPress has date_i18n to retrieve the date in localized format, based on timestamp.

Try:

echo date_i18n("d F Y (H:i)",$date) ;


For the french language I use this

setlocale(LC_ALL, 'fra');echo strftime("%A %d %B %Y",time()); 

For in portuguese

setlocale(LC_ALL, 'ptg');  //echo strftime("%A %d %B %Y",time());

see Language Strings Country/Region Strings.


The documentation for date already answers this:

To format dates in other languages, you should use the setlocale() and strftime() functions instead of date().

And strftime says that the way to do what is by using setlocale:

Format the time and/or date according to locale settings. Month and weekday names and other language-dependent strings respect the current locale set with setlocale().

That said, the C locale-aware functions do not provide sufficient functionality for languages that have cases. In such situations (i.e. most of the time) you need to roll your own.