PHP date()生成具有相同时间戳的不同结果 [英] PHP date() produces different results with same timestamp

查看:280
本文介绍了PHP date()生成具有相同时间戳的不同结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试调试两个服务器之间的PHP日期问题。我正在两个服务器上传递date()函数的时间戳,但是我有两个不同的日期。

I'm trying to debug a php date issue I'm having between 2 servers. I'm passing a timestamp through the date() function on both servers, but I'm getting 2 different dates.

服务器1:

date('d-m-Y', 575766000);
// Outputs 30-03-1988 00:00:00

服务器2: / p>

Server 2:

date('d-m-Y', 575766000);
// Outputs 31-03-1988 00:00:00

我已经检查两个服务器上的日期都是date命令,它们都设置为:

I've checked the date on both servers, with the "date" command, and they're both set to:

Wed Mar  6 14:42:19 GMT 2013

任何想法?

推荐答案

您可以通过登录服务器查看/etc/php.ini来查看时区,具体取决于您的PHP配置方式。

You can check the timezone by logging on to the server and looking at /etc/php.ini depending on how your PHP is configured.

date.timezone =America / New_York

date.timezone="America/New_York"

从PHP 5.3起,您需要设置时区。以前这可以留空。

As of PHP 5.3 you are required to set the timezone. Previously this could be left blank.

这篇关于PHP date()生成具有相同时间戳的不同结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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