Setting the Timezone for PHP in the php.ini file
If you notice the correct time is not displaying in your PHP scripts the likely culprit is that the hosting server is in a different timezone. You can easily resolve this by adding a line of code to your php.ini file. The location you set in the code will determine the time to display in your PHP scripts.
How to Set the PHP Timezone:
- Open your php.ini file with the File Manager in cPanel
Add the following line of code to top of your php.ini file
date.timezone = "US/Central"
- Replace "US/Central" with the timezone from here that corresponds to the time you want to display.
- Once you have entered the desired timezone, click the Save Changes button to save the file.
- Now, you can check your phpinfo.php page to verify the change took place.
If you need further assistance please feel free to ask a question on our support center.
We value your feedback!
There is a step or detail missing from the instructions.
The information is incorrect or out-of-date.
It does not resolve the question/problem I have.
new! - Enter your name and email address above and we will post your feedback in the comments on this page!
2014-05-13 12:17 am
Be sure after you have done this to stop apache and restart apache... Well shut down the web server and restart it again so php will pick up the timezone change.
2014-05-13 9:52 am
Thank you for your comment. But, it is not necessary to restart the server when changing the timezone.
You will also not have the ability to do so in a shared servers setting, since it will bring everyone's site down.
If you have any further questions, feel free to post them below.