为什么日期php和date unix不匹配? [英] why does the date php and date unix does not match?

查看:109
本文介绍了为什么日期php和date unix不匹配?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有centos服务器,我把时间换成纽约时间按日期cmd。
此外,我更改php.inidate.timezone =America / New_York
当我在命令shell中输入命令日期。我在纽约得到实时的时间。
但是当我做

I have centos server and i rechanged the time to NewYork time by date cmd. Also i change in php.ini the "date.timezone = "America/New_York"" When i enter the command date in the command shell. i get the real time in new york. But when I do


echo date(Ymd H:i:s);

echo date("Y-m-d H:i:s");

时间不对!
我总是比纽约的时间少6个小时。
请帮忙?
我试过已经使用date_default_timezone_set('America / New_York');在代码中没有帮助。
等待响应。
谢谢!
Koren或

The time isn't right! I always get 6 hours less then the time in New York. Please help? I tried already using date_default_timezone_set('America/New_York'); in the code with no help. waiting for a response. Thanks! Koren Or

推荐答案


我按时更改纽约时间的时间cmd


i rechanged the time to NewYork time by date cmd

date命令不提供更改时区的方法。你可能把它设置在纽约时间的时间,但是随着任何时区已经被设置,所以你最终服务器的时间是六个小时(奇怪的是,如果是UTC,它应该是5)。

The date command doesn't provide a means to change the timezone. You probably set it to the time that it is in new york time, but as whatever timezone it was already set to, so you ended up with the server time being six hours off (odd, it should be five off if it's UTC).

设置TZ环境变量 export TZ = America / New_York 之前设置时间与date命令。服务器时间不正确会导致严重问题。

Set the TZ environment variable export TZ=America/New_York before setting the time with the date command. Having an incorrect server time can lead to serious problems.

这篇关于为什么日期php和date unix不匹配?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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