I used MySQL function DATE_FORMAT(table.field, '%d %b %Y')
, where the first parameter is my column, and the second is a pattern to format the column according to a date logic.
The output of this function is in english :
10 Feb 2014
And I would like to set the locale language to fr_FR which would output this correct string :
10 Fév 2014
Question : How to change locale language of the DataBase right before the query (in order to change it according to another language) ?
MySQL retrieves and displays DATE values in ' YYYY-MM-DD ' format. The supported range is '1000-01-01' to '9999-12-31' .
MySQL uses yyyy-mm-dd format for storing a date value. This format is fixed and it is not possible to change it. For example, you may prefer to use mm-dd-yyyy format but you can't. Instead, you follow the standard date format and use the DATE_FORMAT function to format the date the way you want.
MySQL comes with the following data types for storing a date or a date/time value in the database: DATE - format YYYY-MM-DD. DATETIME - format: YYYY-MM-DD HH:MI:SS. TIMESTAMP - format: YYYY-MM-DD HH:MI:SS.
you need to set the correct language setting in the MySQL Server. Look here: MySQL DATE_FORMAT() function
The language used for day and month names and abbreviations is controlled by the value of the lc_time_names
system variable (Section 10.7, “MySQL Server Locale Support”).
Run this before your query:
SET lc_time_names = 'fr_FR';
Then set it back to the original value of lc_time_names
;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With