How to set time zone in PHP ini file

By: Kevin | June 4, 2014

If you ever use the date() function in php you’ve likely ran into an error message like this:

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 ‘America/Chicago’ for ‘-5.0/DST’ instead

As the error/warning message suggests you can set


at the top of your php script however that gets to be very repetitive and unnecessary. You could also just silence the warning with the @, however again this doesn’t really solve the problem. To get to the heart of the issue you need to edit the php.ini file. Go ahead and open the php.ini with a notepad editor. *NOTE* On Windows you need to first right click and “Run as Administrator” the on the text editor your choice otherwise sometimes it will not let you save. Add the following to  line to the file then restart Apache for the changes to take affect. A full list of time zones can be found at