Changing the PHP Time Zone Setting
By default, PHP scripts on ruachost.com servers use the US Eastern Standard Time (EST) zone. You can change this setting to match your local time zone by modifying the date.timezone directive in a custom php.ini file.
Why Change the Time Zone?
Section titled “Why Change the Time Zone?”- Ensure timestamps in logs, databases, and applications match your local region.
- Prevent confusion when scheduling tasks or displaying dates to users.
- Improve consistency across applications that rely on accurate time data.
Steps to Change the PHP Time Zone
Section titled “Steps to Change the PHP Time Zone”Step 1: Create or Edit a Custom php.ini File
Section titled “Step 1: Create or Edit a Custom php.ini File”-
Log in to cPanel or access your hosting account via File Manager/SSH.
-
Navigate to your application’s root directory (e.g.,
/public_html). -
Create or edit a
php.inifile. -
Add the directive:
date.timezone = "Africa/Lagos"Replace
"Africa/Lagos"with your desired time zone.
Step 2: Supported Time Zones
Section titled “Step 2: Supported Time Zones”For a complete list of supported time zones, visit the PHP manual time zones list.
Examples:
"Europe/Paris""America/New_York""Asia/Tokyo""Africa/Lagos"
Best Practices
Section titled “Best Practices”- Always set
date.timezoneexplicitly to avoid relying on server defaults. - Use region‑based identifiers (e.g.,
Africa/Lagos) instead of generic ones (GMT,UTC) for clarity. - Test applications after changing the time zone to ensure date/time functions behave correctly.