views:

274

answers:

2
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.

+1  A: 

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.

deceze
This does make sense to me and I suppose it 'must' be true but why would one machine with 1.2.6 throw this error and the other machine with the same version not? Why would the generic app throw the error but my custom app not?The machine throwing the error is a laptop. That's the only difference that I can see. They have the same xampp PHP install. Same versions of everything.
Selino
+1  A: 

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

date_default_timezone_set ("America/Los_Angeles");
Claudio Bredfeldt