How to set the timezone for PHP in the php.ini file

As your hosting server is located at different timezone so sometimes correct time is not displaying on your php script. It can be easily resolve by adding a code line in your php.ini in cPanel of your hosting account. After adding the code the time will displaying as per your entered time zone in your php.ini file.

You can easily enter yourself time zone code in your php.ini file be follow the below steps:

Step 1) Login to your cPanel.

Step 2) Scroll down to Files section and then click on File Manager icon.

Step 3) On the left side of the screen, list of directories of your hosting account is displaying. Here you need to click on public_html folder.

Step 4) In public_html folder, you need to navigate to file public_html > php.ini file.

Step 5) Right click on php.ini file and then click on Edit button as shown in the below screenshot.

Step 6) Now you need to enter the below code line on the top of your php.ini file:

date.timezone = “Africa/Lagos”

Note: You can replace the Africa/Lagos with your own time zone as per your requirment. You can find the php manual here to check the time zone.

Step 7) After entering the above line you need to click on Save Changes button.