简单的PHP日期配置
我正在 windowsXP 中的 localhost 上运行 easyPHP,
现在是
2011-02-07 19:46:00
但是当我尝试 PHP 函数 date() 时,它给了我:
2011-02-08 12:43:00
有人知道怎么做吗要配置这个吗?
i am running easyPHP on localhost in windowsXP
right now its
2011-02-07 19:46:00
but when i try a the PHP function date() it gives me:
2011-02-08 12:43:00
does anybody knows how to configurate this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
使用
date_default_timezone_set('America/New_York')
设置时区。Set your timezone using
date_default_timezone_set('America/New_York')
.您建议的时区不正确。它可以通过 php.ini 进行更改,但是如果 php.ini 无法访问或者您只是想确保安全,那么对代码本身进行简单添加会更理想。
尝试一下,让我知道是否有效。 EST 可能有所不同,但看起来大约是 -5:00 GMT?
祝你好运! :)
Your timezone like suggested was incorrect. It can be changed through php.ini, however a simple addition to the code itself would be more ideal if php.ini is inaccessible or you just want to be safe about stuff.
Give it a try, let me know if it works. EST may be something different but it seems about right -5:00 GMT?
Good luck! :)
因此,在我自己研究这个问题相当长一段时间后,我得出了以下解决方案。如果其他方法对您不起作用,请尝试缓慢而乏味的方法。
在 EasyPHP 安装文件夹中查找名为 php.ini 或 httpd.conf 的任何文件。在每个文件中,确保以下行包含您的首选时区。
这会起作用。对我来说,这是覆盖我的 php.ini 文件的 httpd.conf 文件之一。这会使事情变得难以检测。
So after toying about with this exact issue for quite some time myself, I came to the following solution. If the rest do not work for you, try the painfully slow and tedious way.
Look for any files named php.ini or httpd.conf in your EasyPHP install folder. In each of these files make sure the following line has your preferred time zone.
This will work. For me it was one of the httpd.conf files that was overriding my php.ini file. This can make things difficult to detect.
更改文件
binaries\apache\conf\httpd.conf
在下面的
php_value date.timezone
上为我解决了这个问题:Changing the file
binaries\apache\conf\httpd.conf
on following
php_value date.timezone
did the trick for me: