PHP星期几数字到星期几文本不是英语

Ale*_*rea 1 php codeigniter date setlocale

我试图setlocale()在Windows 上使用函数来转换其他语言的天名,但它不起作用.

<?php setlocale(LC_ALL, 'nl_NL'); 
echo date("l", strtotime($variable); ?>
Run Code Online (Sandbox Code Playgroud)

有没有人可以选择setlocale()?我使用Codeigniter框架.

mag*_*tik 5

你应该考虑使用扩展intl它有IntlDateFormatter.

从文档:

$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);
Run Code Online (Sandbox Code Playgroud)

哪个输出

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
Run Code Online (Sandbox Code Playgroud)