Timezones in Cakephp 1.3 and php 5.3.
Posted by on Fri, Mar 11 2011 00:52:00
I recently updated to php version 5.3.5, and immeiately got the following error in my Cakephp 1.3.x apps:
Warning (2): strtotime() [http://php.net/function.strtotime]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/Chicago' for 'CST/-6.0/no DST' instead [CORE/cake/libs/cache.php, line 570]
Code | Context
$settings = array(
"engine" => "File",
"path" => "/private/var/www/skyrocketstudio.com/app/tmp/cache/persistent/",
"prefix" => "cake_core_",
"lock" => false,
"serialize" => true,
"isWindows" => false,
"duration" => "+10 seconds",
"probability" => 100
)
strtotime - [internal], line ??
CacheEngine::init() - CORE/cake/libs/cache.php, line 570
FileEngine::init() - CORE/cake/libs/cache/file.php, line 81
Cache::_buildEngine() - CORE/cake/libs/cache.php, line 151
Cache::config() - CORE/cake/libs/cache.php, line 126
Configure::__loadBootstrap() - CORE/cake/libs/configure.php, line 420
Configure::getInstance() - CORE/cake/libs/configure.php, line 52
include - CORE/cake/bootstrap.php, line 38
require - APP/webroot/index.php, line 76
[main] - CORE/index.php, line 55
Notice: Trying to get property of non-object in /private/var/www/skyrocketstudio.com/cake/libs/cache/file.php on line 248 Fatal error: Call to a member function cd() on a non-object in /private/var/www/skyrocketstudio.com/cake/libs/cache/file.php on line 248
Turns out it's an easy fix- uncomment date_default_timezone_set('UTC');(around line 242) in your core.php file.
For convenience' sake, here's a list of US timezones, taken from a comment that I always have to refer back to on php.net [http://www.php.net/manual/en/timezones.america.php#93028]
| Common Abbr. | Value for date_default_timezone_set |
|---|---|
| AST | America/Puerto_Rico |
| EDT | America/New_York |
| CDT | America/Chicago |
| MDT | America/Boise |
| MST | America/Phoenix |
| PDT | America/Los_Angeles |
| AKDT | America/Juneau |
| HST | Pacific/Honolulu |
| ChST | Pacific/Guam |
| SST | Pacific/Samoa |
| WAKT | Pacific/Wake |