Change Month Name to French

change month name to french

From http://php.net/manual/en/function.date.php:

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

convert month name (french) to month number

Please let me know if I can convert the month name to English, when it
is being created

This is pretty easy, to change month name to English (or other languages) replace:

deb_period_curr = Format(premier_jour, "mmm")

With (first 3 letters):

deb_period_curr = WorksheetFunction.Text(premier_jour, "[$-409]mmm")

Or (full name):

deb_period_curr = WorksheetFunction.Text(premier_jour, "[$-409]mmmm")

TEXT formula supports country codes. 409 is US English, but you can find a list of languages and some more info here.

To get 2 digit month number you can use for example:

deb_period_curr = Format(premier_jour, "mm")

display month name in french in php?

Assuming your website's base language is French, you can make use of the built-in WordPress function date_i18n() like this:

echo date_i18n( 'F j  H:i', $ts ); //Assuming $ts is your time stamp

If $ts is actually a date object, you will have to grab the timestamp first like this:

echo date_i18n( 'F j  H:i', $ts->getTimeStamp() ); //Assuming $ts is a dateTime object

If you are struggling with a timezone difference (i.e. the time returned is a few hours ahead/behind) then you will need to combine the function with get_date_from_gmt like this:

$correct_date = get_date_from_gmt(date_format($ts, 'Y-m-d H:i:s')); //gets the date in your current timezone
echo date_i18n( 'F j H:i', strtotime($correct_date) );

How do I get French month names in PHP in this existing script?

<? 
setlocale (LC_TIME, 'fr_FR.utf8','fra');
echo (strftime("%A %d %B"));

?>

this is another approach that i have found somewhere in SO

$date = str_replace(
array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'),
array('Januar', 'Februar', 'März', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember'),
$date
);

I need to return Arabic/French month name out of Date object

you do not have to work around it. Use SimpleDateFormat(format, locale). Here is the code example:

    SimpleDateFormat fen = new SimpleDateFormat("dd/MMMM/yyyy", new Locale("en"));
SimpleDateFormat ffr = new SimpleDateFormat("dd/MMMM/yyyy", new Locale("fr"));

Date date = new Date();

System.out.println(fen.format(date));
System.out.println(ffr.format(date));

Month Name in regional language and wanted in English

Building on @Amit great response, I would say: =TEXT(B1;"[$-409]mmm").

As the English name of Month are already capitalized on the first letter.

If it's not enough, there is the Proper function that will only capitalize the first letter of the word.


format mmm already is 3 char long in English. No need for LEFT(). Proper() capitalizes the first char only.

Note that using 040C for French for example, it might return longer strings ! E.g: "Juil." for July.



Related Topics



Leave a reply



Submit