2011-12-15 58 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