如果我在 core.php 中使用
Configure::write('Config.timezone', 'Europe/Paris');
显示的时间将少于 2 小时
date_default_timezone_set('Europe/Paris');
我应该在我的 core.php 中设置其他内容吗?
谢谢。
如果我在 core.php 中使用
Configure::write('Config.timezone', 'Europe/Paris');
显示的时间将少于 2 小时
date_default_timezone_set('Europe/Paris');
我应该在我的 core.php 中设置其他内容吗?
谢谢。
您应该检查该配置值上方的注释:
Config.timezone
可以在其中设置用户的时区字符串。如果调用 CakeTime 类的方法,将 $timezone 参数设置为 null 并Config.timezone
设置,则将使用 的值Config.timezone
。此功能允许您只设置一次用户的时区,而不是每次在函数调用中传递它。
Config.timezone
配置值仅适用于CakeTime
实用程序类,如果没有明确将时区传递给它,它将使用该值。
为了配置内置 PHP 函数使用的时区,您必须使用date_default_timezone_set()
.
也可以看看