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:
-
Log into cPanel.
-
Navigate to File Manager:
- Scroll down to the Files section and select File Manager.
-
Access the public_html Directory:
- In the left panel, locate and click on the public_html folder, where your website files are stored.
-
Locate or Create php.ini:
- Look for the
php.ini
file in thepublic_html
folder. - If it doesn’t exist, click on the +File button at the top, type
php.ini
, and then click Create New File.
- Look for the
-
Edit the php.ini File:
- Right-click on
php.ini
and choose Edit.
- Right-click on
-
Set the Timezone:
- Add the following line at the top of the file, replacing
"Place/Your_town"
with your timezone (e.g.,"Europe/London"
): - Example:
- Add the following line at the top of the file, replacing
-
Save Changes:
- Click Save Changes to update your settings.
-
Verify the Change:
- Check your
phpinfo.php
page (if available) to confirm the timezone is set correctly.
- Check your
This will ensure that PHP displays the time based on your specified timezone in php.ini
.