Setting Timezones in PHP Print

  • 0

By default, 4xhost servers use Coordinated Universal Time (UTC). If you need a different timezone, you can change it by editing the date.timezone directive in your php.ini file.

PHP relies on this setting for accurate date/time functions. Sometimes, an error appears in the server logs indicating a need to set this value. Here’s how you can easily configure it:

  1. Log into cPanel.

  2. Navigate to File Manager:

    • Scroll down to the Files section and select File Manager.
  3. Access the public_html Directory:

    • In the left panel, locate and click on the public_html folder, where your website files are stored.
  4. Locate or Create php.ini:

    • Look for the php.ini file in the public_html folder.
    • If it doesn’t exist, click on the +File button at the top, type php.ini, and then click Create New File.
  5. Edit the php.ini File:

    • Right-click on php.ini and choose Edit.
  6. Set the Timezone:

    • Add the following line at the top of the file, replacing "Place/Your_town" with your timezone (e.g., "Europe/London"):
      date.timezone = "Place/Your_town"
    • Example:
      date.timezone = "Europe/London"
  7. Save Changes:

    • Click Save Changes to update your settings.
  8. Verify the Change:

    • Check your phpinfo.php page (if available) to confirm the timezone is set correctly.

This will ensure that PHP displays the time based on your specified timezone in php.ini.


Was this answer helpful?

« Back