且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

为什么我的 time() 在 php 中减少了一小时?

更新时间:2023-12-02 15:53:04

您可以通过在 PHP 脚本中明确设置时区来解决它.您可以使用 date_default_timezone_set() 做到这一点:

You solve it by setting the timezone explicitly in your PHP scripts. You can do this with date_default_timezone_set():

date_default_timezone_set('America/Los_Angeles');

这里是PHP 支持的时区列表.

您可能还想尝试调用 的测试脚本date_default_timezone_get() 查看它的实际设置,以验证这确实是问题所在.

You may also want to try a test script calling date_default_timezone_get() to see what it's actually set to to verify that this is in fact the problem.