可能重复:
strtotime With Different Languages?
Get list of localized months
我从数据库中获取日期时间并将其格式化为:
$row['datetime'] = date('jS F Y',strtotime($row['datetime']));
这将采用以下格式:
28th March 2012
我如何本地化月份的名称,所以对于法国用户来说,它会显示火星而不是三月?
由于
答案 0 :(得分:8)
使用setlocale
和strftime
获取日期字符串的本地化版本。
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'";
答案 1 :(得分:2)