PHP日期,国际月份名称?

bea*_*ans 7 php

可能重复:
使用不同语言的strtotime?
获取本地化月份列表

我从数据库中获取日期时间并将其格式化为:

$row['datetime'] = date('jS F Y',strtotime($row['datetime']));
Run Code Online (Sandbox Code Playgroud)

这将采用以下格式:

28th March 2012
Run Code Online (Sandbox Code Playgroud)

我如何本地化月份的名称,所以对于法国用户来说它会显示火星而不是三月?

谢谢

Joh*_*man 8

使用setlocalestrftime获取日期字符串的本地化版本.

PHP文档示例 - http://php.net/manual/en/function.setlocale.php:

/* Set locale to Dutch */
setlocale(LC_ALL, 'nl_NL');

/* Output: vrijdag 22 december 1978 */
echo strftime("%A %e %B %Y", mktime(0, 0, 0, 12, 22, 1978));

/* try different possible locale names for german as of PHP 4.3.0 */
$loc_de = setlocale(LC_ALL, 'de_DE@euro', 'de_DE', 'de', 'ge');
echo "Preferred locale for german on this system is '$loc_de'";
Run Code Online (Sandbox Code Playgroud)

  • 但请注意[`setlocale`将语言环境进程设置为宽](http://php.net/manual/en/function.setlocale.php#refsect1-function.setlocale-notes)(在使用多个线程时导致多线程出现意外行为) -threading).线程安全替代:[IntlDateFormatter](http://php.net/manual/en/class.intldateformatter.php) (4认同)