Knowledge Base
MilesWeb / How-Tos

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

Approx. read time : 2 min

If the correct time is not displaying in your PHP scripts, you will need to make some changes on your hosting server. This can be easily done by adding a line of code to your php.ini file.

So let’s see how to set the Timezone for PHP:

Step 1: Open your php.ini file with the File Manager in cPanel

Step 2: Add the below-mentioned line of code to top of your php.ini file

Step 3: Replace “US/Central” with the timezone from here that corresponds to the time you want to display.

Step 4: Once you have entered the timezone you want to set, click the Save Changes button to save the file.

Step 5: Now, you can check your phpinfo.php page to verify the change took place.

Before:

After:

Related: Modifying the PHP.INI file

Avatar
Pravin is Journalist Specializing in Blogging, Social Networking and Community Management. As a constant learner, he is always aiming towards new ideas and greater knowledge. When he is not doing research, reading, or writing for blogs, you can find him hanging around social media sites.