Setting the timezone on PHP

This post was published 8 years, 10 months ago. Due to the rapidly evolving world of technology, some concepts may no longer be applicable.

Versions of PHP after 5.10 include the date.timezone directive in php.ini. Many applications which reference time need this directive to be set. A list of accepted values can be found at: http://www.php.net/manual/en/timezones.php

The timezone is set as a quoted string, with no delimiter at the end, for example:

date.timezone = "Continent/City"

The location of the php.ini file that is in use can be found by loading a php file containing the following:

<?php phpinfo(); ?>

The resulting output will list, among other things, ‘Configuration File (php.ini) Path’ (typically, /etc).

Restart apache (or other server) for the changes to take effect:

service httpd restart

Leave a Reply

Your email address will not be published. Required fields are marked *