A Web.com Partner
Sign Up / Log In
Online Support Web Hosting

How to Change the PHP Time Zone Using php.ini

If your PHP scripts are in an incorrect time most likely the reason for this is your hosting server is in a different timezone. But if you want to change it, you can do so by adding a line of code in your php.ini file that will determine the correct time you wish to display in your PHP scripts. Read through this article to learn how.

How to Set the PHP Timezone

You need to have a php.ini file to make this work. If you don’t have one yet, please visit this linked guide to learn how to create a php.ini file. Then, follow the steps below to change your PHP timezone.

  1. Access your File Manager.
  2. Scroll to public_html folder and locate your php.ini file.
  3. Right-click on the php.ini file and click Code Edit. A pop-up window will appear, click Edit to continue to the editor page.
  4. Add the following code at the top of your php.ini file.
    date.timezone = "US/Central"
  5. Replace US/Central to your preferred time zone. The location you set determines the time that displays in your PHP scripts.
  6. Click Save Changes to update file.

Congratulations! You just changed your time zone for PHP. You can view your PHP information via your phpinfo page. Visit this linked guide to learn how to to create and view phpinfo page. Please let us know if you need any further assistance, or if you have any questions. We’d love to help!

Was this helpful? Yes No 41% of people found this helpful.
{"message":""}