PHP date() in foreign languages - e.g. Mar 25 Ao#251; 09(外语中的 PHP date() - 例如09 年 3 月 25 日)
问题描述
我有一个脚本需要向国际观众显示日期数据 - 例如
I have a script that needs to display date data to an international audience - e.g.
2009 年 8 月 25 日星期二提交"
"submitted Tue 25 Aug 09"
有没有更简单/更干净的方法可以将其转换为法语(等)等效的Mar 25 Aoû 09"?比:
Is there an easier/cleaner way to get this converted to the French(etc) equivalent "Mar 25 Aoû 09" than:
设置一个常量 LANG 和一个包含文件的 $LANGUAGES 数组 &:
Setting a constant LANG and a $LANGUAGES array of include files & :
if(LANG != 'EN')
{
include $LANGUAGES['LANG'];
}
&然后包含的文件映射天 &月&替换适当的语言环境?
& then the included file maps the days & months & replaces for the appropriate locale?
推荐答案
我认为如果不设置 LOCALE 就无法避免这样做:
I think you can't get away from doing so without setting LOCALE:
<?php
setlocale(LC_ALL, 'fr_FR');
echo strftime("%A %e %B %Y");
?>
关于strftime的一些细节:http://us2.php.net/manual/en/function.strftime.php
Some details on strftime: http://us2.php.net/manual/en/function.strftime.php
这篇关于外语中的 PHP date() - 例如09 年 3 月 25 日的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:外语中的 PHP date() - 例如09 年 3 月 25 日
基础教程推荐
- 如何在 Laravel 中使用 React Router? 2022-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
- 在PHP中根据W3C规范Unicode 2022-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
- 如何替换eregi() 2022-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
