Introduction


PHP relies on the date.timezone value for some date/time functions executed by php-based applications. Sometimes you even get an error message on your webserver logs that clearly indicates this necessity.


Fortunately, this is easy to accomplish and we will show you how. For this guide, we will be using CentOS 6 with root privileges.


Open the php.ini file


On CentOS, the php.ini file is located at the /etc directory.

sudo vi /etc/php.ini

Depending on the installed version of PHP version, you will find a [Date] section like the following. If it is not there, just add a line with the "date.timezone = Your/Timezone" function.

[Date]
; Defines the default timezone used by the date functions
; http://www.php.net/manual/en/datetime.configuration.php#ini.date.timezone
date.timezone = 

Uncomment the date.timezone function and set its value to the timezone you need. In this case we will use America/New_York. To see a list of supported timezones, refer to php.net

[Date]
; Defines the default timezone used by the date functions
; http://www.php.net/manual/en/datetime.configuration.php#ini.date.timezone
date.timezone = America/New_York

Now, save and exit the php.ini file.


Restart Apache webserver


In order for the changes to take effect, you need to restart the Apache webserver:

sudo service httpd restart

Congratulations, you have set the timezone in php.ini file.

 
 

Test on a Miami VPS Now

or

Deploy on a Miami Dedicated Server

Hai trovato utile questa risposta? 6 Utenti hanno trovato utile questa risposta (13 Voti)