PHP:为什么我的日期在服务器上不同? [英] PHP: why is my date formated on the server differently?

查看:118
本文介绍了PHP:为什么我的日期在服务器上不同?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用以下源代码,我可以在dev(local-maxOSX)和live(debian)上获得不同的输出:

With following source code I get different outputs on dev (local-maxOSX) and live (debian):

setlocale(LC_TIME, 'de_DE' ); 
$intervalOutput = strftime('%a %d.%m. %H:%M', $start->getTimestamp());
echo $intervalOutput;

本地(正确格式化的一天):Do 01.03。 20:00

local (correct formatting of the day): Do 01.03. 20:00

实时服务器(不正确 - 我需要德国工作日的输出):Thu 01.03。 20:00

live server (incorrect- i need german weekday output): Thu 01.03. 20:00

有人可以告诉我为什么会这样吗?

Can someone tell my why this happens?

推荐答案

我以为这对我有用(这就是为什么我在这里写这个答案),但后来我意识到这不是在开发(OSX)机器上工作。 (所以我刚刚编辑这个答案)
你可以尝试它:

I thought this worked for me (thats why I wrote this answer here), but later on I realised that this is not working on the dev (OSX) machine now. (So I just edited this answer) You can try it anyway:

1)在实时服务器上安装语言环境(以root用户身份):

1.) installing locales on the live server (as root):

aptitude install debconf
dpkg-reconfigure locales

2。)更改:

setlocale(LC_TIME, 'de_DE')

setlocale(LC_TIME, 'de_DE.UTF8')

为什么这不适合我,似乎是在OSX上,locale被称为
de_DE.utf-8,而在debian机器上被称为de_DE.UTF8。

The reason why this is not working for me, seems to be that on OSX the locale is called "de_DE.utf-8" whereas it is called "de_DE.UTF8" on the debian machine.

这篇关于PHP:为什么我的日期在服务器上不同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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