问题描述
在我的特殊情况下,服务器和客户端都是同一台计算机,我在本地主机上.当我从 date() 函数中回显日期时,它显示了一个完全错误的值,早了 11 小时.我也试过 gmdate(),但它显示的是上午而不是下午的日期.有什么办法可以改变apache服务器的时间,所以每次我在php中得到它时,它显示的时间和我电脑上的时间一样吗?
In my particular case, both the server and the client are the same computer, I'm on localhost. When i echo out the date from the date() function, it displays a totally wrong value, a 11 hours earlier time. I also tried gmdate(), but it displays the date in AM not PM. Is there any way to change the apache server time, so everytime I get it in php, it displays the same as the time on my computer?
抱歉编辑晚了.我已经在 php.ini 中设置了时区,但它仍然不起作用.而且我确定我的时区是正确的,因为我从手册中得到它并从 phpinfo() 中检查.
Sorry for the late edit. I have already set the timezone in the php.ini but it still doesn't work. And I'm sure that my timezone is correct, since I got it from the manual and checked from phpinfo().
推荐答案
我相信您正在寻找:date_default_timezone_set ( string $timezone_identifier )
您也可以在 php.ini 配置中进行设置.
You can also set this in your php.ini config.
这篇关于如何更改apache服务器中的时间以使其与计算机的时间(PHP)相匹配?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!