如何更改MySql中的'Timestamp'列列语言? [英] How to change 'Timestamp'-column language in MySql?

查看:112
本文介绍了如何更改MySql中的'Timestamp'列列语言?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一列是Timestamp。

I have a column which is a Timestamp.

它记录如下: 2010-02-08 12:10:22

It records something like: 2010-02-08 12:10:22

然后我在php中使用这个:

Then I use this in php:

 $postdate = date( "j F", strtotime( $row['modify_date'] ) );

它可以输出如下: 2月8日

我的问题是,如何更改日期文本,以便输出其他语言的月份名称(特别是瑞典语)?

My Q is, how can I change the date-text so it outputs the month name in another language (swedish specifically)?

例:1月是瑞典语Januari

Ex: January is in Swedish Januari

谢谢

推荐答案

本地PHP函数是 strftime()

The native PHP function for that is strftime().


%B 全月份名称,根据地区1月至12月

%B Full month name, based on the locale January through December

如果服务器不在瑞典语区域,请使用 setlocale()

if the server is not in the swedish locale, use setlocale().

那么说,我有这么多麻烦, code> setlocale()在过去,特别是共享托管,我倾向于保留一系列的月份名称在任何配置文件/字典文件项目具有:

That said, I have had so many troubles with setlocale() in the past, especially on shared hosting, that I tend to keep an array of month names in whatever config file / dictionary file the project has:

$monthnames["de"] = array("Januar", "Februar", "März", "...");
$monthnames["fi"] = array("Tammikuu", "Helmikuu", "...");


echo $monthnames[$language][date("n", strtotime( $row['modify_date'] ))]; 

这篇关于如何更改MySql中的'Timestamp'列列语言?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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