How do I set default timezone in cakephp?

余生颓废 提交于 2019-12-23 09:41:17

问题


So I have a system that is mostly finished, just ironing out some final bugs. We have an issue that the program seems to be permanently set in the New York timezone.

I have this line of code in both core.php and bootstrap.php:

date_default_timezone_set("Australia/Melbourne");

But the system keeps reporting that it is in America/NewYork.

Can anyone help me set the timezone to Australia Melbourne?


回答1:


In the config/core.php file of the app folder try the following with single quotes:

date_default_timezone_set('Australia/Melbourne');



回答2:


You can add this in config/core.php:

Configure::write('Config.timezone', 'Europe/London');



回答3:


Set timezone in App/Config/bootstrap.php (Cakephp 2.6+)

date_default_timezone_set('Europe/Dublin');
ini_set('date.timezone', 'Europe/Dublin');
//Configure::write('Config.timezone', 'Europe/Dublin');



回答4:


As of CakePHP 3.x, the configuration for default timezone is found in config/bootstrap.php.

CakePHP uses the PHP timezone codes, which can be found in the PHP docs here: http://php.net/manual/en/timezones.php

For example, a server in Los Angeles will be configured like this: date_default_timezone_set('America/Los_Angeles');



来源:https://stackoverflow.com/questions/22625181/how-do-i-set-default-timezone-in-cakephp

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!