如何将英文日期格式转换为德语日期格式 [英] how to convert english date format to german date format in php

查看:220
本文介绍了如何将英文日期格式转换为德语日期格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这样的日期格式

(英文格式)

 15. July 2011

我想用德语格式转换它, / p>

And I want to convert it in German format like this

15. Juli 2011

如何将日期格式从一个滞后转换为其他语言格式?

How to convert date format from one laguage to other language format?

我的代码是

 $date = '15. July 2011';
 $newLocale = setlocale(LC_TIME, 'de_DE');
 $date = strftime('%d. %B %Y',$date);

但这不是转换我得到七月而不是 Juli

But this is not converting I am getting July rather than Juli

推荐答案

你可以使用 setlocale 函数> date function:

You could use setlocale function before calling date function:

$newLocale = setlocale(LC_TIME, 'de_DE', 'de_DE.UTF-8');

编辑: strftime docs:

Quote from strftime docs:


如果您的系统中安装了相应的区域设置,则此示例将工作。

This example will work if you have the respective locales installed in your system.

这篇关于如何将英文日期格式转换为德语日期格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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