views:

566

answers:

4

hi all,

on server i have php 5.3.2, and cakephp 1.3.

when i run cakephp application, it gives me following errors:

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 'Europe/Berlin' for 'CEST/2.0/DST' instead [ROOT/cakephp/cake/libs/cache.php, line 570]

Also, I'm getting some more errros:

Notice: Trying to get property of non-object in /htdocs/cakephp/cake/libs/cache/file.php on line 248 Fatal error: Call to a member function cd() on a non-object in /htdocs/cakephp/cake/libs/cache/file.php on line 248 

Timezone in php.ini is defined as Europe/London

I'm ALWAYS getting that error, despite I define or not date_default_timezone_set('UTC'), or Europe/London, or whatever...

really frustrating......... please help...

UPDATE: something is wrong with my installation of php... if i run

<?php echo date('Y'); ?>

... it gives me blank screen. no result...

is there maybe a problem?

A: 

If you Google:

"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. php"

you will find 1.78 million results. The answers are in there.

It's not you, it isn't even CakePhp - it's PHP 5.3

Leo
what can i do now?
Well, like I said, the answers are out there. You could try date_default_timezone_set('Europe/London'); in webroot/index.php, config/bootstrap.php or config/core.php. Just experiment - that's how you'll learn. Then let us know what worked for you.
Leo
A: 

To handle the first warning you need to uncomment the line date_default_timezone_set('UTC'); in /app/config/core.php. You can replace UTC with your timezone as Leo suggested.

bancer
unfortunately, i did that before i post this question... also i tried several different timezones, and get same error every time. also, please check UPDATED part of my question... for some reason, i can not execute simple php function date. i think that there may be a problem, something i did not enabled, or installed, or...?
Change your file to `<?php error_reporting(E_ALL); echo date("Y"); ?>`.
bancer
i did set error_reporting(E_ALL), and errors i'm getting are: Warning: date(): 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 'Europe/Berlin' for 'CEST/2.0/DST' instead in /htdocs/index.php on line 9 Fatal error: date(): Timezone database is corrupt - this should *never* happen! in /htdocs/index.php on line 9
That is php bug http://bugs.php.net/bug.php?id=48882. Try to add TZ=GMT in (apache) init.d script. If that does not help ask the question on http://serverfault.com
bancer
A: 

I had the exact same problem and Googling led me to this post.

I fixed the problem by adding the line date_default_timezone_set("America/Anchorage"); to the top of [cake base directory]/libs/cache.php

You probably want to replace America/Anchorage with your timezone.

Adam Prax
A: 

As Leo Said, is an issue with PHP 5.3. The best solution is to modify your web server php.ini and set

[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = "Europe/Rome"

Or if you can't modify web server php.ini you can add this options to root .htaccess file on your site:

php_flag date.timezone = "Europe/Rome"
Valentino Dell'Aica