有关特定国家/地区的mysql日期格式 [英] mysql date format regarding to a specific country

查看:91
本文介绍了有关特定国家/地区的mysql日期格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用了MySQL函数DATE_FORMAT(table.field, '%d %b %Y'),其中第一个参数是我的列,第二个参数是根据日期逻辑格式化列的模式.

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.

此函数的输出为英语:

10 Feb 2014

而且我想将语言环境语言设置为 fr_FR ,它将输出此正确的字符串:

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 Server中设置正确的语言设置.在这里查看: MySQL DATE_FORMAT()功能

you need to set the correct language setting in the MySQL Server. Look here: MySQL DATE_FORMAT() function

用于日期和月份名称和缩写的语言由lc_time_names系统变量的值控制(第10.7节"MySQL服务器区域设置支持").

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").

在查询之前运行此命令

SET lc_time_names = 'fr_FR';

然后将其设置回lc_time_names的原始值;

Then set it back to the original value of lc_time_names;

这篇关于有关特定国家/地区的mysql日期格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆