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.

I keep getting this error:

Message: date() [function.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 'America/New_York' for 'EST/-5.0/no DST' instead

I have edited my php.ini and added this to the end of it: date.timezone = "America/New_York"

After saving the php.ini and restarting Apache, I still get the error. I have also tried rebooting the entire server to no avail.

I'm running cPanel/WHM on CentOS 5.6 if that makes any difference. Also, the PHP handler is suphp.

I'm not sure what to try next... any guidance?

share|improve this question
On my setup, I have many php.ini (apache, cli, php-fpm, etc…) did you edit the right one? –  greut Jan 14 '12 at 10:19
Its not an error its a message so everything will work fine but php is informing you that its not good idea to rely on system timezone setting .. thats all ... but its strange that after you changed setting the message is still there :/ –  B14D3 Jan 14 '12 at 11:26
Presuming you have the right php.ini file, 3 observations (although all may be irrelevant): a) There should already be an entry for date.timezone in your php.ini file (i.e. your new entry might not take precedence) b) There is a specific [Date] section in php.ini - which is not at the bottom of the file, entries outside of that might not be processed as expected; c) The timezone doesn't need to be quoted - again, I am uncertain of the effect. Try php -i | grep timezone and see what you get. –  cyberx86 Jan 16 '12 at 17:17

4 Answers 4

open the appropriate php.ini file and add the following, replacing the time zone with the one which is correct for you (list of timezone names - http://php.net/date.timezone):

; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = "America/Chicago"

for a little more detail:


share|improve this answer

It sounds like there may be more than one php.ini on your system and the wrong one has been edited. I believe it is possible to specify a different php.ini directory per vhost with suPHP (using the suPHP_ConfigPath option).

There are a couple of options open to you. Firstly: you could (as the error message suggested) use:


However, this does make your code less portable.

Alternatively you can double-check which php.ini file is being loaded when the script executes by creating a phpinfo page; i.e. just a web-accessible php file with the following content:


View the page and look for the sections marked "Loaded Configuration File" and "Additional .ini files parsed". These should tell you which ini files you need to be editing.

It is worth checking all of the files listed as any of them may contain misspelt date.timezone settings that are overriding the one you have set.

share|improve this answer

I fixed this by removing the quotes around the string value.


date.timezone = "Europe/London"


date.timezone = Europe/London

and the problem went away. I am a little concerned by this though.

share|improve this answer

I just solved this problem. At first, I thought the wrong php.ini was being read. After many checks, I found out the problem. This was, that I had an extra ' in the middle of the php.ini, so it was getting an error there, preventing the rest from loading. I fixed it, and it works perfect. You can see if there's any error by running the following: php -i | grep php.ini | tail -n2

share|improve this answer

Your Answer


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.