2011-12-15 67 views
4

即时通讯设法用strftime打印德语日期。我已经试过Strftime与德国日期

date_default_timezone_set('Europe/Berlin'); 
setlocale(LC_ALL, "de_DE", "[email protected]", "deu", "deu_deu", "german"); 
$time = strftime("%B", 1323956220); 
echo $time; //I want to see "Dezember", but I see "December" instead 

但它没有工作。我错过了什么吗?

编辑:对不起,我错过了strftime的功能可按:P

+1

你能展示你的整个代码吗?再次, – 2011-12-15 14:10:57

+1

什么没有工作? – ajreal 2011-12-15 14:11:21

回答

10

我的猜测:语言环境实际上在您的机器上名为(它在我的机器上)。这对你有用吗?

setlocale(LC_ALL, "de_DE.utf8"); // or LC_TIME 
echo strftime('%B', 1323956220); 

BTW:在Linux上,您可以使用locale -a来查看可用内容。

-1

你需要的国际化扩展安装,但我建议使用IntlDateFormatter class

先看看说明书,但一个简单的例子可能是这样的:

$fmt = datefmt_create("de_DE", IntlDateFormatter::FULL, IntlDateFormatter::NONE, 'Europe/Berlin', IntlDateFormatter::GREGORIAN); 
echo datefmt_format($fmt , time()); 

它输出这样的:

Donnerstag,15 。Dezember 2011