How to Set the TimeZone in PHP

January 19, 2024 / Web Hosting

This article explains how to set the TimeZone in PHP. Users need to set the TimeZone if they notice an incorrect time in their PHP scripts. This variation is mostly seen when a user located in a different TimeZone.

Let us find out how to set the TimeZone in PHP:

  1. Log in to cPanel.
  2. Select the “File Manager” option under “Files” section.
    files>File manager
  3. Locate “php.ini” file, right click and click on the “Edit” button.
  4. Insert the subsequent code line at the beginning of your php.ini file: date.timezone = “UK/Central”.
  5. Substitute “UK/Central” with the TimeZone obtained from this source that corresponds to the desired time display.
  6. After entering the preferred TimeZone, save the file by clicking on “Save Changes”.
    Save changes
  7. You can now check your phpinfo.php page to confirm the change took place.

That is it! Hope you understood our article and that you can set the TimeZone in PHP. For more latest updates, do visit our KB section regularly.

Spread the love