First, we need to identify which PHP configuration file your server is using. To do this, connect to your server via SSH and run the following command:

php -i | grep php.ini

If your server uses cPanel, you will typically see a path like this in the output:

/usr/local/lib/php.ini

  1. Edit the PHP Configuration File

Open the identified PHP configuration file (for example, /usr/local/lib/php.ini) using nano or your preferred text editor:

nano /usr/local/lib/php.ini

  1. Update the Timezone Settings

Once the file is open, find the line starting with date.timezone. It will currently have a timezone set, like:

date.timezone = "America/New_York"

Change this to the timezone you want. For Turkey, you can use:

date.timezone = "Europe/Istanbul"

  1. Save Changes and Exit

To save the changes in nano, press Ctrl + X, then Y, and then Enter to exit.

  1. Restart the Web Server

To apply the changes, you need to restart your web server. This is usually done with one of these commands:

service apache2 restart

or

service nginx restart

Your PHP timezone issue should now be resolved, and your web applications will work with the correct date and time. By following these steps, you can easily update PHP’s timezone settings.

Did you find it useful?
(37 times viewed / 0 people found it helpful)