[英]PHP day of week numeric to day of week text not English
I tried to use setlocale()
function on windows to convert days name in other language but it didn't work. 我试图在Windows上使用
setlocale()
函数将日期名称转换为其他语言,但没有用。
<?php setlocale(LC_ALL, 'nl_NL');
echo date("l", strtotime($variable); ?>
does anybody have an alternative for setlocale()
? 有人可以替代
setlocale()
吗? I use the Codeigniter framework. 我使用Codeigniter框架。
You should consider using the extension intl
which has IntlDateFormatter
. 您应该考虑使用具有
IntlDateFormatter
的扩展名intl
。
From the documentation : 从文档中 :
$fmt = new IntlDateFormatter( "en_US" ,IntlDateFormatter::FULL,IntlDateFormatter::FULL,'America/Los_Angeles',IntlDateFormatter::GREGORIAN );
echo "First Formatted output is ".$fmt->format(0);
$fmt = new IntlDateFormatter( "de-DE" ,IntlDateFormatter::FULL,IntlDateFormatter::FULL,'America/Los_Angeles',IntlDateFormatter::GREGORIAN );
echo "Second Formatted output is ".$fmt->format(0);
which output 哪个输出
First Formatted output is Wednesday, December 31, 1969 4:00:00 PM PT
Second Formatted output is Mittwoch, 31. Dezember 1969 16:00 Uhr GMT-08:00
nl_NL
is a typical Unix style locale name. nl_NL
是典型的Unix风格的语言环境名称。 On Windows, locales follow a different format . 在Windows上,语言环境采用不同的格式 。 You want "nld", "holland", or "netherlands" .
您需要“ nld”,“荷兰”或“荷兰” 。
Additionally, date()
is not locale-aware. 此外,
date()
不支持区域设置。 You probably want strftime()
. 您可能需要
strftime()
。
setlocale(LC_ALL, 'german');
echo (iconv('ISO-8859-2', 'UTF-8', strftime('%Y. %B %d. (%A)', mktime('0', '0', '0', '6', '18', '2010'))));
setlocale(LC_ALL, 'hungarian');
echo (iconv('ISO-8859-2', 'UTF-8', strftime('%Y. %B %d. (%A)', mktime('0', '0', '0', '6', '18', '2010'))));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.