Question

PHP Warning:  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 ge
tting this warning, you most likely misspelled the timezone identifier. We selected 'America/Los_Angeles' for '-8.0/no D
ST' instead in C:\xampp\htdocs\cake_1_2\cake\libs\cache.php on line 429

I only get this when I try to use bake in a new cakephp 1.2.6 app. If I run bake in the default app folder (the one that comes with the cake build) it does this. If I run bake from my old 1.2.5 project (cake_1_2/myapp) it works fine.

Is anyone else having this issue with CakePHP 1.2.6 projects?

It's not a PHP problem because then it would be consistent with any time functions I tried.

Was it helpful?

Solution

Well, it is a PHP problem. See description of date_default_timezone_set:

Note: Since PHP 5.1.0 (when the date/time functions were rewritten), every call to a date/time function will generate a E_NOTICE if the timezone isn't valid, and/or a E_WARNING message if using the system settings or the TZ environment variable.

and

5.3.0 Now throws E_WARNING rather then E_STRICT.

As the warning message states, Cake neglects to use date_default_timezone_set to explicitly set a timezone, which is considered unreliable, hence the warning. This only seems to be the case for the CLI app. I don't know if there's a regression between 1.2.5 and 1.2.6, but 1.3 should definitely be compliant with PHP 5.3's standards.

You can easily get rid of this warning yourself by simply setting the timezone in the /cake/console/cake.php script.

OTHER TIPS

In stead of modifying core files, add your timezone into ./app/config/core.php

date_default_timezone_set ("America/Los_Angeles");

I uncommented the 232 line in ./app/config/core.php . I am using 2.2.3 version.

This is the line:

/**
 * Uncomment this line and correct your server timezone to fix 
 * any date & time related errors.
 */
date_default_timezone_set('UTC');
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top