php - 不能用德语读取日期 [英] php - can't get date in german language

查看:175
本文介绍了php - 不能用德语读取日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试用德语显示日期,但无效。我正在使用PHP与XAMPP。

I try to display a date in German but it doesn't work. I'm using PHP with XAMPP.

这些是我的方法:

function get_Datetime_Now() {
setlocale (LC_TIME, "de_DE");
$tz_object = new DateTimeZone('Europe/Zurich');
$datetime = new DateTime();
$datetime->setTimezone($tz_object);     
return $datetime->format('l, d. F Y  ');
}

echo get_Datetime_Now();

它返回2014年2月9日星期日,但我不会Sonntag,09. Februar 2014(德语)。

It returns "Sunday, 09. February 2014" but I wan't "Sonntag, 09. Februar 2014" (German language).

我也尝试过:

setlocale(LC_TIME, "de_DE");
echo strftime("%A, %d. %B %Y");

它还返回2014年2月9日星期日。我在互联网上看到很多例子,不起作用(至少在我的环境中)。

It also returns "Sunday, 09. February 2014". I saw many examples on the internet, which don't work (at least on my environment).

有哪些设置需要检查?

感谢任何帮助!

提前Thx,
shivan

Thx in advance, shivan

推荐答案

你可能使用的是一台Windows机器,其PHP语言代码与基于Unix的语言代码不同。

You are probably using a windows machine which has different language codes in PHP than a Unix based one.

尝试:

setlocale(LC_TIME, 'de_DE', 'deu_deu');

这将首先尝试将其设置为'de_DE'(Linux / Unix),并将'deu_deu'代码作为Windows的回退(PHP Version> = 4.3)。

This will first try to set it to 'de_DE' (Linux/Unix) and have the 'deu_deu' code as a fallback for windows (PHP Version >= 4.3).

德语PHP示例文件

这篇关于php - 不能用德语读取日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆