更改php日期输出语言
我使用几个变量以如下所示的格式存储不同的php日期:更改php日期输出语言,php,date,strtotime,strftime,Php,Date,Strtotime,Strftime,我使用几个变量以如下所示的格式存储不同的php日期: $today = date('Y-m-d'); $todayPretty = date('d. M'); $oneMonthBefore = date('Y-m-d', strtotime('-1 months')); $oneMonthBeforePretty = date('d. M', strtotime('-1 months')); $oneMonthBefore2 = date('Y-m-d', strtotime($this-&g
$today = date('Y-m-d');
$todayPretty = date('d. M');
$oneMonthBefore = date('Y-m-d', strtotime('-1 months'));
$oneMonthBeforePretty = date('d. M', strtotime('-1 months'));
$oneMonthBefore2 = date('Y-m-d', strtotime($this->oneMonthBefore .' -1 day'));
$oneMonthBefore2Pretty = date('d. M', strtotime($this->oneMonthBefore .' -1 day'));
$twoMonthsBefore = date('Y-m-d', strtotime('-2 months'));
$twoMonthsBeforePretty = date('d. M', strtotime('-2 months'));
$currentMonth = date('F');
$previousMonth = date('F', strtotime('-1 months'));
不幸的是,我需要他们使用不同的语言,例如丹麦语,因此我设置了以下内容,但没有结果:
setlocale(LC_ALL, "da_DK.UTF-8");
我已经读到,我必须使用
strftime
函数,但是在我的例子中,当涉及到不使用strftime
的变量时,我应该如何处理这个问题?欢迎您提供任何帮助或指导。首先,您应该检查您是否已安装了以下语言环境:
locale -a
在命令行中
如果没有,您可以在ubuntu/debian上通过以下方式实现:
sudo locale-gen da_DK.UTF-8
在PHP中,如果您的代码将在windows上开发并部署在linux上,您还可以尝试多个deff,如下所示:
<?php
setlocale (LC_ALL, 'de_DE.UTF-8', 'de_DE@euro', 'de_DE', 'de', 'ge', 'de_DE.ISO_8859-1', 'German_Germany');
通用的:
setlocale(LC_ALL,'nl_NL.UTF-8');
窗户
setlocale(LC_ALL,'nld_nld');
对于linux
setlocale(LC_ALL, 'nl_NL');
如果这不起作用,那么您必须创建一个代码段[[!setlocale]]
并把这个,
并在前面调用此代码段!DOCTYPE
或html
调用不同的语言,如日期格式或实际翻译的单词?(subsiday
=Tirsdag
)我需要这些词:)我用的是str_replace
,但这太过分了:(你试过echo strftime(“%d.(%A)%B',strotime(“-1个月”);
?@Glavić我试过,但没有成功你试过setlocale(LC ALL,“da_DK.UTF-8”,“dash丹麦”,“丹麦”)
?我尝试使用以下代码查看是否安装了德语示例:date\u default\u timezone\u set('european/Berlin');$loc=setlocale(LC\u ALL,'de_DE@euro'、'de_de'、'deu_deu');回显strftime('%B')
而且似乎仍在用英语告诉我月份名称。您必须在发行版的命令行上安装所有需要的区域设置。您有什么类型的?Debian、Ubuntu等等。。。?
setlocale(LC_ALL,'nl_NL.UTF-8');