问题
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