翻译 date("d FY (H:i) function php
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14821998/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Translate date("d F Y (H:i) function php
提问by Lucas Bustamante
I'm brazilian and there's a wordpress plugin that uses
我是巴西人,有一个 wordpress 插件使用
" . date("d F Y (H:i)",$date) . "
Output: 16 January 2013 (00:54)
输出:2013 年 1 月 16 日 (00:54)
But it should be 16 Janeiro 2013 (00:54), in portuguese... How can I change it?
但它应该是 16 Janeiro 2013 (00:54),葡萄牙语...我该如何更改它?
PS: I think maybe the date is set by an external file provided by the plugin creator :p I'm not sure though
PS:我想日期可能是由插件创建者提供的外部文件设置的:p我不确定
回答by RRikesh
回答by Marc Voet
For the french language I use this
对于法语,我使用这个
setlocale(LC_ALL, 'fra');
echo strftime("%A %d %B %Y",time());
For in portuguese
对于 葡萄牙语
setlocale(LC_ALL, 'ptg'); //
echo strftime("%A %d %B %Y",time());
see Language Strings Country/Region Strings.
请参阅语言字符串国家/地区字符串。
回答by Jon
The documentation for datealready answers this:
的文档date已经回答了这个问题:
To format dates in other languages, you should use the setlocale() and strftime() functions instead of date().
要格式化其他语言的日期,您应该使用 setlocale() 和 strftime() 函数而不是 date()。
And strftimesays that the way to do what is by using setlocale:
并strftime说这样做的方法是使用setlocale:
Format the time and/or date according to locale settings. Month and weekday names and other language-dependent strings respect the current locale set with setlocale().
根据区域设置格式化时间和/或日期。月份和工作日名称以及其他与语言相关的字符串尊重使用 setlocale() 设置的当前语言环境。
That said, the C locale-aware functions do not provide sufficient functionality for languages that have cases. In such situations (i.e. most of the time) you need to roll your own.
也就是说,C 语言环境感知函数没有为具有 case 的语言提供足够的功能。在这种情况下(即大部分时间),您需要自己动手。

