user2787386
user2787386

Reputation: 303

How do I set default timezone in cakephp?

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?

Upvotes: 7

Views: 25157

Answers (4)

Aaron Chamberlain
Aaron Chamberlain

Reputation: 671

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');

Upvotes: 2

Arvind K.
Arvind K.

Reputation: 1304

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');

Upvotes: 3

kythan06
kythan06

Reputation: 126

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

date_default_timezone_set('Australia/Melbourne');

Upvotes: 10

Arelancelot
Arelancelot

Reputation: 501

You can add this in config/core.php:

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

Upvotes: 5

Related Questions