Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

on server i have php 5.3.2.

if i want to run simple php script, like this :

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

...it gives me following errors:

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

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

I tried to edit /etc/init.d/httpd file, but i don't have permissions (due to selinux?)

please help...

share|improve this question

1 Answer 1

That's not a PHP bug - it's telling you something is wrong, and you need to correct it.

I notice the line Timezone database is corrupt - this should never happen! - try the following command in your shell and restart Apache: apt-get install tzdata.

If it's still broken after that (or you already have that package), create a new PHP file with the following contents and load it up in a browser: <?php phpinfo(); ?>.

Look for Loaded Configuration File and check that is the php.ini file you are editing.

Open that php.ini file and look for the line beginning date.timezone. Make sure the timezone you are selecting is enclosed in quotes - the one I use is as follows: date.timezone = "Europe/London".

Once you've modified and saved php.ini, you must reload Apache for the change to take effect.

share|improve this answer
    
ben, my tzdata is installed and reinstalled (yum install tzdata-2010j i run yesterday, and today yum reinstall tzdata-2010j). also in /etc/php.ini i do have line date.timezone = "Europe/Berlin". also i have edited correct php.ini (i do not have two php.ini files on my system). –  user48058 Aug 1 '10 at 15:48
    
and, running phpinfo(), in timezone section still have error Warning: phpinfo(): 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/info.php on line 1 –  user48058 Aug 1 '10 at 15:49
    
and apache is of course reloaded... –  user48058 Aug 1 '10 at 15:50
    
to mention, i tried with Europe/Berlin, Europe/Moscow, Europe/London, also, i tried with UTC ... –  user48058 Aug 1 '10 at 16:00

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.